-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix(types): avoid any in react.ts #941
Conversation
@devanshj review request |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 99d5054:
|
Size Change: +1 B (0%) Total Size: 29 kB
ℹ️ View Unchanged
|
selector: StateSelector<TState, StateSlice> = api.getState as any, | ||
equalityFn?: EqualityChecker<StateSlice> | ||
) { | ||
const slice = useSyncExternalStoreWithSelector( | ||
api.subscribe, | ||
api.getState, | ||
// TODO avoid `any` and add type only in react.ts |
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.
We simply allow specifying optional getServerState
property. Note this has nothing to do with vanilla.ts.
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.
Out of curiosity - do you have any examples of how Zustand consumers should utilize getServerState
nowadays? When I think about it (in the context of just any state management library) it seems quite cumbersome to provide this, especially if a given library supports multiple stores. I wonder if we could figure out a standard way for approaching this problem.
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.
Out of curiosity - do you have any examples of how Zustand consumers should utilize
getServerState
nowadays?
No. Here, the API is just exposed, hoping to find a way to utilize it somehow.
I wonder if we could figure out a standard way for approaching this problem.
Definitely. In the zustand case, I was hoping if someone come up with some ideas or concrete use cases. There might be a standard way.
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.
Looks good.
I originally thought this requires StoreMutator, but it doesn't actually mutate. So, it's rather simple?
Yep, only middlewares require StoreMutator
.
There was a
TODO
in react.ts.I originally thought this requires StoreMutator, but it doesn't actually mutate. So, it's rather simple?