Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KamyarTaher authored Jul 27, 2024
1 parent 808c2ca commit 1517a62
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ const { useSelectors, setDeep } = createStore(initialState);

// Example of using selectors
function ExampleComponent() {
// Automatic type inference and path suggestion for all functions' input and output
// 'user.name' and 'settings.theme' are inferred as strings, then name and theme will be suggested
// Automatic type inference and path suggestion for all functions' input and output.
const { age } = useSelectors('user.age');
// You can simply select as many state you want
const { name, theme } = useSelectors('user.name', 'settings.theme');
// 'user.name' and 'settings.theme' are inferred as strings, then name and theme will be suggested

// Update state at any depth just by specifying the path
const onClick1 = () => setDeep('user.name', 'Jane');
// Also, you can have access to the current state and return a new one
// You can have access to the current state and return a new one
const onClick2 = () => setDeep('settings.theme', (prev) => prev === 'light' ? 'dark' : 'light');

return (
Expand Down

0 comments on commit 1517a62

Please sign in to comment.