reusable icon indicating copy to clipboard operation
reusable copied to clipboard

Question: Did you use this package with React 17

Open DirkWolthuis opened this issue 3 years ago • 10 comments

We've updated our app to React 17, but encountered weird bugs where state updates did not get back in other components where the store was used. It's a complex app, but downgrading to React 16 fixed these bugs for us. I will try to make a real bug report, but have any of you encountered this problem?

DirkWolthuis avatar Apr 29 '21 08:04 DirkWolthuis

Hi, I haven't. @morsdyce ?

adamkleingit avatar Apr 29 '21 11:04 adamkleingit

I haven't used react 17 yet due to some bugs occurring in component libraries but it's usually related to event handling and not state.

Could you reproduce the issue with any of the examples we have?

morsdyce avatar Apr 29 '21 15:04 morsdyce

I will give it a try when I have the time. It was a combination of useReducer in a store and a child component that did not received the updated values. Tried debugging it a while but only downgraded to react 16 helped. Will let you know when I’ve created a example.

Op do 29 apr. 2021 om 17:11 schreef Maayan Glikser @.***

I haven't used react 17 yet due to some bugs occurring in component libraries but it's usually related to event handling and not state.

Could you reproduce the issue with any of the examples we have?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/reusablejs/reusable/issues/123#issuecomment-829320093, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACMAFWUHTTWHHBM7542PHE3TLFZILANCNFSM43ZMWAVA .

DirkWolthuis avatar Apr 29 '21 16:04 DirkWolthuis

create store:

export const useStore = createStore(() => useState({}));

and use them:

const store = useStore()

returns store === null for the React 17

gev avatar May 01 '21 22:05 gev

There is a different babel version in the react 17. Could it be a reason?

gev avatar May 02 '21 11:05 gev

Babel shouldn't be the issue as we don't convert syntax using a babel plugin. I tried reproducing a simple example with React 17 and it worked:

https://codesandbox.io/s/compassionate-fog-ltf4x?file=/src/App.js

It would really help if you could send an example of it not working correctly

morsdyce avatar May 02 '21 11:05 morsdyce

one more note, I use react native. It not depends from react-dom

gev avatar May 02 '21 12:05 gev

@gev could you reproduce the issue on expo? I don't have an environment ready for react-native

morsdyce avatar May 02 '21 12:05 morsdyce

Can't reproduce at expo. All works as well. On my envirenment bug exists when import custom hook from module.

gev avatar May 02 '21 14:05 gev

create store:

export const useStore = createStore(() => useState({}));

and use them:

const store = useStore()

returns store === null for the React 17

We had a very similar issue in react-native with React 17 that appears to be caused by the import for the store not actually executing the imported file until a function from it is used. With stores that usually happens within the render method, during which you don't want to be changing around your stores. The solution was to add an "empty" import of the store directly to our App.tsx: import 'stores/thestore'

CarpeNecopinum avatar Feb 17 '22 13:02 CarpeNecopinum