API
flow
This is a iFlow standard connector API
import flow from 'react-iflow'
flow' is a higher-order function, and it also supports the use of decorator.
If iFlow the last parameter into store, the connector for the current component will use this store first
- Selector
In fact most of the time, You don't need to pass store and write selector, because iFlow supports Provider and iFlow will automatically help all sub-components distinguish state usage. and automatically determine if the state in which the various components are being used is updated to determine that the component needs to be updated, unless you need to compute the derived data.
- Use higher-order functions
class CustomComponent extends Component {}
flow(store)(CustomComponent)
- Simpler
Provider+connectusage
import { connect } from 'react-iflow'
class CustomComponent extends Component {}
connect(CustomComponent)
Provider
import { Provider } from 'react-iflow'
ReactDOM.render(<Provider store={store}><Body/></Provider>, document.getElementById('app'))
Providerdepend on thecontextof react to complete the transfer and sharing of the state, if you are familiar with react-redux, then iFlow'sProviderusage rules are similar.
connect
import { connect } from 'react-iflow'
class CustomComponent extends Component {}
connect(CustomComponent)
- When you use
Providerto insert into the app root component, you can use theconnectAPI to quickly connect and inject state, which is very simple and effective.