We build our site using reaction / reaction-router / reduction
We want the server side to display our pages, which should be populated with data from our data sources. This transaction must be asynchronous and, unfortunately, since we want to render on the server side, we cannot use the componentDidMount function.
On the reduction manual page in the server-side rendering section here , it was recommended:
If you use something like a React Router, you can also express your data select dependencies as static fetchData () methods on your route handler components. They can return asynchronous actions so that your handleRender function can map the route to the route handler class of components, send the result fetchData () for each of them and visualize it only after Promises are enabled. In this way, the specific API calls required for different routes are placed along with the route for defining handler components. You can also use the same method on the client side to prevent the router from switching the page to its data loaded.
We are currently processing our data sample. I personally did not like this approach, it looks rather awkward, and it is too connected with the routing library. Are there any better ways to do this - hopefully with standard reaction / router / reduct components?
javascript asynchronous reactjs redux react-router
ralzaul
source share