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
Generally using setters inside an effect is suggestive of a problem with data structuring, and it prevents Solid's runtime from automatically doing analysis of reactive dependencies.
There is a similar issue with stores, but createWriteable doesn't work there (too high perf cost), so it is an open question if there are any easy fixes in that case.
I would be willing to contribute a PR to implement this feature
The text was updated successfully, but these errors were encountered:
Fortunately, I think this will be simple to implement as its own rule outside of solid/reactivity so it can be maintained and enabled separately. This is limited to createSignal and createEffect only I presume?
Supplying an auto-fix could be more difficult, and I’m not totally convinced that a writable is much better of a solution, so I think just warning makes sense here.
Awesome! This rule applies to any combination of signals/stores, and effect/computed/renderEffect/memos. And yeah, maybe linking to a docs page/this issue for ideas on how to restructure your state to fix this lint would be good.
It may currently be impossible to fix the issue for all stores without a new core primitive, so ideally that part of the lint would be toggleable.
Describe the need
Generally using setters inside an effect is suggestive of a problem with data structuring, and it prevents Solid's runtime from automatically doing analysis of reactive dependencies.
This is an example of potentially unsafe code
Safe code might be:
Suggested Solution
Ideally, a new lint would be added to the reactivity lint that looks for code and recommends restructuring the signals to avoid this pattern.
Possible Alternatives
Using the following helper function (this may be included in the Solid core in a future version)
Then the following code (which should fail the lint)
Can be rewritten as follows:
Additional context
There is a similar issue with stores, but createWriteable doesn't work there (too high perf cost), so it is an open question if there are any easy fixes in that case.
The text was updated successfully, but these errors were encountered: