components
directory should contain React Native JSX components, which take their inputs in as props
. In Flux/Redux parlance the components should be dumb/presentation components, meaning that components should not be connect()
ed to the redux store directly, but instead used by smart/container components.class Foo extends Component
class or as a plain JavaScript function component. Usage of React.createClass
should be avoided, as it will be deprecated in 15.5.android.js
and .ios.js
files for the component. In minor cases the React.Platform.OS
property can be used to branch between platforms.connect()
ing the View component to the Redux store.connect()
takes in two arguments, first mapStateToProps
which selects relevant parts of the application state to pass to the view, and second mapActionsToProps
, which binds Action Creators to the store's dispatcher so the actions are executed in the right context. These functions are often called selectors.mapStateToProps
is a good practice, but avoid using mapActionsToProps
in favour of calling dispatch
ourselves in the view. In our experience this leads to simpler, easier to reason about code (and a little less verbose PropTypes on the View).recompose
to give you an ability to manage state, lifecycle events and more inside your containers, not components. Check you the docs at https://github.com/acdlite/recompose