Is it worth using Redux when using Relay?

A Simple Pattern for Using Relay and Redux Together

Luckily, it turns out the basics of using the two together is not that complex. Both Redux and Relay work by defining a higher-order component that wraps a regular (presentational) React component. We have found that we can use the two together by implementing a 3-tier structure: our presentational component is first wrapped by a Redux container, which is then wrapped by a Relay container. In the outermost level we have our Relay container for fetching data. This data is then passed via props to the Redux container. This component can then use these props and any other props passed in from further up in the tree. This data can then simply be passed further along to the presentational component if needed, or used as part of dispatching actions that will occur on the page. Here is where we see the separation of concerns I mentioned earlier – the presentational component handles the display, while the Relay and Redux containers handle the business logic. This logic is then further separated – logic surrounding the behavior of the page is defined by Redux, while logic for fetching and updating data is handled by Relay.

ref: http://beautifulcode.1stdibs.com/2016/09/07/reconcile-relay-redux/

Conversations on Redux Github: https://github.com/reactjs/redux/issues/464
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s