-
-
Notifications
You must be signed in to change notification settings - Fork 251
Add React 18 compatibility #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Name | Link |
---|---|
🔨 Latest commit | 7afe4ab |
443fdb5
to
3981efa
Compare
506533e
to
0d638e8
Compare
<div> | ||
<p>{prefix}</p> | ||
<p>{text}</p> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment for 004da3e
const user = createStore('guest') | ||
const friends = createStore<string[]>([]) | ||
const user = createStore('guest', {sid: 'user'}) | ||
const friends = createStore<string[]>([], {sid: 'friends'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment for a2e04ee
}, [store, scope]) | ||
const subscribe = (cb: () => void) => createWatch(store, cb, scope) | ||
const read = () => stateReader(store, scope) | ||
const currentValue = useSyncExternalStore(subscribe, read, read) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Third argument is getServerSnapshot
- in case of effector there is no difference with client version
https://reactjs.org/docs/hooks-reference.html#usesyncexternalstore
@AlexandrHoroshih What about to upgrade react-17 to react-18? |
@sergeysova It is upgraded in the repo 🤔 It is implementation of |
@AlexandrHoroshih Oh, yeah. I see that https://github.com/AlexandrHoroshih/effector/blob/react-18/package.json#L96-L99 |
keep old fixture for backward compatibility tests
effector-react must be updated to work correctly with react-18, but at the same time it should not break react-17 compatiblity
due to substitution of react-18 to react-17 sids may be different each time
TODO: remove, once react-17 support is deprecated
bug is not reproduced, hmm
react-dom of 18 renders empty string slightly different, but it is not a concern of tests for effector-react at all also IS_REACT_ACT can just be always true, since react-17 does not know about that
refactor react 17 script
Previous custom implementation prevented re-computation of `fn`, if none of the keys in `useStoreMap` was changed This test catches this behaviour and will pass with previous implementation, but currently it fails with the new one, based on official `use-sync-external-store`, since `useSyncExternalStoreWithSelector` does not accept keys Need to add some custom memoization for that in the new implementation
It is needed to comply with previous behavior of useStoreMap
inline condition instead of function, one return instead of few
86c12ec
to
6a350de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Big thanks 🙏🏻
Closes #643
Changelog
react
andreact-dom
to latest 18.x.x versionreact-17
version - changes forreact-18
compatibility should not break usage of effector withreact-17
effector-react
implementation to officialuseSyncExternalStore
for integration withreact-18
and shim ofuseSyncExternalStore
forreact-17
fn
inuseStoreMap
- previous implementation prevented re-computation offn
during render, if both store state and keys were not changed. New implementation must keep this behaviour (test: 6790129)