Skip to content
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

Merged
merged 1 commit into from Apr 29, 2022
Merged

fix(types): avoid any in react.ts #941

merged 1 commit into from Apr 29, 2022

Conversation

dai-shi
Copy link
Member

@dai-shi dai-shi commented Apr 29, 2022

There was a TODO in react.ts.
I originally thought this requires StoreMutator, but it doesn't actually mutate. So, it's rather simple?

@dai-shi dai-shi added this to the v4.0.0 milestone Apr 29, 2022
@dai-shi
Copy link
Member Author

dai-shi commented Apr 29, 2022

@devanshj review request

@codesandbox-ci
Copy link

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:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
React Parcel Configuration
Next.js Configuration

@github-actions
Copy link

Size Change: +1 B (0%)

Total Size: 29 kB

Filename Size Change
dist/system/index.production.js 386 B +1 B (0%)
ℹ️ View Unchanged
Filename Size
dist/context.js 518 B
dist/esm/context.js 448 B
dist/esm/index.js 400 B
dist/esm/middleware.js 2.95 kB
dist/esm/middleware/immer.js 210 B
dist/esm/shallow.js 272 B
dist/esm/vanilla.js 377 B
dist/index.js 642 B
dist/middleware.js 3.07 kB
dist/middleware/immer.js 373 B
dist/shallow.js 318 B
dist/system/context.development.js 572 B
dist/system/context.production.js 393 B
dist/system/index.development.js 575 B
dist/system/middleware.development.js 3.04 kB
dist/system/middleware.production.js 1.97 kB
dist/system/middleware/immer.development.js 292 B
dist/system/middleware/immer.production.js 187 B
dist/system/shallow.development.js 338 B
dist/system/shallow.production.js 253 B
dist/system/vanilla.development.js 444 B
dist/system/vanilla.production.js 270 B
dist/umd/context.development.js 662 B
dist/umd/context.production.js 488 B
dist/umd/index.development.js 787 B
dist/umd/index.production.js 564 B
dist/umd/middleware.development.js 3.18 kB
dist/umd/middleware.production.js 1.97 kB
dist/umd/middleware/immer.development.js 514 B
dist/umd/middleware/immer.production.js 371 B
dist/umd/shallow.development.js 447 B
dist/umd/shallow.production.js 344 B
dist/umd/vanilla.development.js 590 B
dist/umd/vanilla.production.js 378 B
dist/vanilla.js 456 B

compressed-size-action

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
Copy link
Member Author

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.

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.

Copy link
Member Author

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.

Copy link
Contributor

@devanshj devanshj left a 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.

@dai-shi dai-shi merged commit da10075 into main Apr 29, 2022
@dai-shi dai-shi deleted the fix/types/react-no-any branch April 29, 2022 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants