indiana-university / conduit

A JavaScript library for architecting user interfaces with RxJS and React.
BSD 3-Clause "New" or "Revised" License
5 stars 0 forks source link

Connect: Update for React 16 and 17 #10 #3

Open basham opened 5 years ago

basham commented 5 years ago

csbasham commented on Apr 10, 2018


There's a lot of changes with React's lifecycle methods and asynchronous rendering, that's happening in React 16.3 and 17. Start to work on compatibility.

basham commented 5 years ago

csbasham commented on Apr 27, 2018


componentWillReceiveProps is the only lifecycle method we'll need to figure out.

getDerivedStateFromProps is being added as a safer alternative to the legacy componentWillReceiveProps.

References:

basham commented 5 years ago

csbasham commented on Apr 27, 2018


Perhaps there's a way to use getDerivedStateFromProps if it's there; otherwise, use componentWillReceiveProps. That way, it doesn't introduce a hard change.

basham commented 5 years ago

csbasham commented on Apr 27, 2018


From what I can tell, there doesn't need to be any changes to prepare for async rendering. It just means that connect() may be simplified, because React, instead of RxJS, could handle rendering only on animation frame.

basham commented 5 years ago

anderjak commented on Apr 30, 2018


If I'm understanding the docs correctly, for the work that's done in Conduit's connect function's componentWillReceiveProps we should be able to just replace componentWillReceiveProps with getDerivedStateFromProps, possibly with the addition of a return null; to indicate there should be no state update.

This could be another change for which we just have obvious documentation about which version of React works with which version of Conduit.

basham commented 5 years ago

csbasham commented on Apr 30, 2018


Yes, I think the code impact will be minimal. But it does require the newer version of React. Perhaps v0.4 is the release to do that forced change?

basham commented 5 years ago

anderjak commented on Apr 30, 2018


Based on what I've seen so far about async rendering I'm not sure that there isn't still some benefit to keeping the animationFrame-based stream emissions both for state and lifecycle functions. I think it might require some experimentation to see how well it works just relying on React to make all the rendering smooth.

basham commented 5 years ago

anderjak commented on Apr 30, 2018


Forcing React changes with v0.4 of Conduit seems reasonable to me. I expect we'd want to bundle all the updates that require a React upgrade together. Maybe upgrading for React 16.3+ compatibility could be the main goal or just one of the goals for the v0.4 release.