helix

7tupel 2023-09-21T13:59:28.284319Z

Hi, has anyone tried to use multiple react versions in the same project? Background, I'm evaluating to use helix for a project in which I would like to use react 18 but I'm required to use an external library for UI components that only supports react 16. Has anybody done something similar with success?

lilactown 2023-09-21T16:26:36.574909Z

IIRC, React 17 made a bunch of changes to allow the ability to run React 17 and React 18

lilactown 2023-09-21T16:27:54.483719Z

they changed they way event propagation works to happen at the root node of the app instead of listening to the document IIRC

lilactown 2023-09-21T16:28:28.545819Z

it is otherwise largely no change from 16 to 17. it took us about a month to upgrade from 16 to 17 because we had a bunch of really gross hacks in our app to handle global event propagation that we didn't need anymore (and were subtly broken) after upgrading

lilactown 2023-09-21T16:30:05.659619Z

that being said, I've never done it, and AFAICT you'd need to separate it into two apps - one that's React 18, and one that's React 16.

7tupel 2023-09-21T16:33:43.578479Z

Yes I'm afraid the only way will be to have separate react apps and mount one inside the other. I would take the UI component library and try to make it react 18 compatible but the library is not open source and the bundle of the library I got is not exactly a charm to make it compatible with react 18

7tupel 2023-09-21T16:37:31.767599Z

I guess it should be possible to build pure ui components using the library and then mount that component as r16 app inside another r18 app that provides the state handling and only passing the needed data down to the pure ui as props. Yet this will likely require to re-mount the whole r16 app when the props change I need to pass to the r16 app's root component. Not exactly a maintainable and easy to debug codebase

lilactown 2023-09-21T19:04:54.909319Z

what blocks you from using React 18 with the component library?

lilactown 2023-09-21T19:06:01.136019Z

it sounds like you ought to use react 16 until the library is updated for 18 tbqh

7tupel 2023-09-21T19:13:43.874539Z

Unfortunately the components library breaks with react newer than 16 :/ otherwise it would not have been a thing in the first place