You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `Provider` is required for any of its child components to consume fragmented-store hooks.
113
+
114
+
```js
115
+
importcreateStorefrom"fragmented-store";
116
+
117
+
const { Provider } =createStore({
118
+
username:"Aral",
119
+
age:30
120
+
});
121
+
122
+
functionApp() {
123
+
return (
124
+
<Provider>
125
+
{/* rest */}
126
+
</Provider>
127
+
);
128
+
}
129
+
```
130
+
131
+
### Fragmented store
132
+
133
+
The power of this library is that you can use fragmented parts of the store, so if a component uses only one field of the store, it will only re-render again if there is a change in this particular field and it will not render again if the other fields change.
134
+
135
+
For each of the fields of the store, there is a hook with its name, examples:
The advantage of this library is to use the store in a fragmented way. Even so, there are cases when we want to reset the whole store or do more complex things. For these cases, we can use the hook `useUnfragmentedStore`.
0 commit comments