-
-
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
Update docs content #2508
base: main
Are you sure you want to change the base?
Update docs content #2508
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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. |
I figured you wanted feedback on the structure, not a review, because there are a lot of placeholders there. I think the structure is fine, the reference section definitely will help. You can consider renaming the learn directory to recipes, because learn suggests a step-by-step guide, a tutorial of some sort in which you can master this library. Something like https://go.dev/learn/ or https://tanstack.com/learn. The |
I can also strongly recommend any IntelliJ-based IDE for documentation with the Grazie Pro plugin. I've got IntelliJ IDEA Ultimate, but it also works with Community Edition and I think the new editor, Writerside. IntelliJ Community Edition and Writerside are free, so you won't have to pay anything. I haven't tested Writerside, so I don't know about its performance. You can also check out Vale, a command-line tool, albeit with some IDE integrations, but I haven't tested it either. |
@sewera what about the structure or the topics? do you have a topic in mind that you would like to see BTW, I don't like intellij-idea but thanks for the suggestions |
The structure is good, especially the split between reference and recipes. One thing I'd do differently is to split it more: recipes, like "Persisting State with Persist Middleware," guides, like "Starting a new project," and reference, like "createWithEqualityFn." |
@sewera btw, I found this tool that use languagetool -> https://marketplace.visualstudio.com/items?itemName=valentjn.vscode-ltex&ssr=false#review-details |
@sewera actually, I'm following React Docs Pattern -> https://react.dev and there would be a tutorial (tic-tac-toe) same as react docs but with zustand |
Alright, that makes sense. Quick start with tic-tac-toe tutorial and installation are in one section, "Get Started," and recipes are in "Learn React." That's a good idea to use the React pattern, probably the best in this scenario :) |
`createStore` returns a vanilla store with some API utilities. These API utilities are: `setState` | ||
function, `getState` function, and `subscribe` function. | ||
|
||
### `setState` function |
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.
I feel like such functions like setState
should be in one place, with hyperlinks to them from, e.g., combine
function to avoid copying.
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.
@sewera that's not supported with the current setup but when we migrate to vitepress we can move everything in one place and then just import them
@dai-shi lmk what you think about reference section and documentation, still working on usage and troubleshooting section but apart from that everything else should be done on reference section |
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.
Reviewed the reference docs.
[`getState` function](#getstate-function) and [`storeApi`](#storeapi) as arguments. It should | ||
return an additional state based on the initial state. |
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.
Do we have those for combine
?
|
||
#### Returns | ||
|
||
`combine` returns a new state that is the result of merging the initial state and the additional |
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.
More precisely, combine
and any other middleware "returns" a state creator.
@@ -0,0 +1,106 @@ | |||
--- | |||
title: createContext |
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.
Please remove this from the reference.
The `getState` function lets you access to the current state. It can be stale on asynchronous | ||
operations. |
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.
Not sure if "stale on async operations" is technically correct.
### `createWithEqualityFn` Signature | ||
|
||
```ts | ||
createWithEqualityFn<T>()(initializer: StateCreator<T, [], []>, equalityFn: (a: T, b: T) => boolean): UseBoundStore<StoreApi<T>> |
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.
createWithEqualityFn<T>()(initializer: StateCreator<T, [], []>, equalityFn: (a: T, b: T) => boolean): UseBoundStore<StoreApi<T>> | |
createWithEqualityFn<T>()(initializer: StateCreator<T, [], []>, equalityFn?: (a: T, b: T) => boolean): UseBoundStore<StoreApi<T>> |
- `initializer`: The value you want the state to be initially. It can be a value of any type, but | ||
when you pass a function should take `setState` function, `getState` function and `storeApi` as | ||
arguments. | ||
- `equalityFn`: A function that lets you skip re-renders. |
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.
it's optional and by default Object.js
will be used.
### `combine` Signature | ||
|
||
```ts | ||
combine<T, U>(initialState: T, additionalStateCreator: StateCreator<T, [], [], U>): Omit<T, keyof U> & U |
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.
Shouldn't we clarify where we can import this from? combine
is from zustand/middleware
.
|
||
#### Returns | ||
|
||
`create` returns a React Hook: |
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.
More precisely, it returns a React hook (function) with Store API attached.
|
||
# shallow | ||
|
||
`shallow` function lets you optimize re-renders. |
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.
- shallow is a comparison function
- it can be used as a custom equality function to optimize re-renders.
|
||
# useShallow ⚛️ | ||
|
||
`useShallow` is a React Hook lets you memoized a selector function. |
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.
It doesn't memoize anything.
`useShallow` is a React Hook lets you memoized a selector function. | |
`useShallow` is a React Hook that lets you optimize re-renders. |
Summary
Updating docs content
Check List
yarn run prettier
for formatting code and docs