@cervello/react 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Cervello
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@cervello/react)
|
|
4
|
-
[](https://bundlephobia.com/package/@cervello/react@latest)
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
<a href="https://www.cervello.dev">
|
|
@@ -60,6 +60,29 @@ export const {
|
|
|
60
60
|
useSelector, // Hook to listen for changes on parts of the store
|
|
61
61
|
reset, // Function to reset the store to initial value
|
|
62
62
|
} = cervello({ count: 0 })
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// With the store object you can use it outside of React components
|
|
66
|
+
const increment = () => store.count++
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const Button = () => {
|
|
70
|
+
const { count } = useStore() // Listen for changes on the whole store
|
|
71
|
+
return (
|
|
72
|
+
<button onClick={increment}>
|
|
73
|
+
{count}
|
|
74
|
+
</button>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const ButtonWithSelector = () => {
|
|
79
|
+
const { count } = useSelector(['count']) // Listen for changes just on count property
|
|
80
|
+
return (
|
|
81
|
+
<button onClick={increment}>
|
|
82
|
+
{count}
|
|
83
|
+
</button>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
63
86
|
```
|
|
64
87
|
<br>
|
|
65
88
|
<br>
|