@@ -91,15 +91,39 @@ const [state, setState] = createStore({
9191Note that modifying an array inside a store will not trigger computations that subscribe to the array directly. For example:
9292
9393```ts
94+ // After Solid 1.4.0
9495createEffect(() => {
95- console .log (state .todos );
96+ // This will not get triggered because we've subscribed to the array itself.
97+ console .log (todos );
9698} );
99+ setTodos(todos.length, { id : 3 } );
97100
98- //This will not trigger the effect:
101+
102+ // Prior to Solid 1.4.0
103+ createEffect(() => {
104+ // This will not get triggered because we've subscribed to the array itself.
105+ console .log (state .todos );
106+ } );
99107setState(todos, state.todos.length, { id : 3 } );
108+ ```
109+ However, subscribing to any signals that change inside the array will trigger those computations.
110+ ```ts
111+ // After Solid 1.4.0
112+ createEffect(() => {
113+ // This will be triggered because we've subscribed to the actual signals in the array.
114+ console .log ([... todos ]);
115+ console .log (todos [2 ]) // Or we can subscribe only to a specific one.
116+ } );
117+ setTodos(todos.length, { id : 3 } );
118+
100119
101- //This will trigger the effect, because the array reference changes:
102- setState("todos", (prev) => [...prev, { id : 3 } ]);
120+ // Prior to Solid 1.4.0
121+ createEffect(() => {
122+ // This will be triggered because we've subscribed to the actual signals in the array.
123+ console .log ([... state .todos ]);
124+ console .log (state .todos [2 ]) // Or we can subscribe only to a specific one.
125+ } );
126+ setState(todos, state.todos.length, { id : 3 } );
103127```
104128
105129## Updating Stores
0 commit comments