Small suggestion about calculating the bufferGap value:
I understand that it is probably here for the sake of example of createEffect usage, but you could avoid having unnecessary rerender caused when updating bufferGap state by storing the state dependant value in a ref. It could look something like this:
Because we store the value in a ref, it allows us to perform all calculations without cascading state updates. We would avoid unnecessary calculations since we only update the ref value the condition is met.
I believe something like this should be possible in Solid
This is where SolidJS shines over React IMO (at least one of the main places).
The component function is called only once. There will be no unnecessary renders.
No need for ref. You know exactly the state of your component as it only reacts to changes and not renders in its entirety.
This is freaking awesome, and sooooo simple to reason about.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Small suggestion about calculating the
bufferGapvalue:I understand that it is probably here for the sake of example of createEffect usage, but you could avoid having unnecessary rerender caused when updating
bufferGapstate by storing the state dependant value in a ref. It could look something like this:Because we store the value in a ref, it allows us to perform all calculations without cascading state updates. We would avoid unnecessary calculations since we only update the ref value the condition is met.
I believe something like this should be possible in Solid
This is where SolidJS shines over React IMO (at least one of the main places).
The component function is called only once. There will be no unnecessary renders.
No need for ref. You know exactly the state of your component as it only reacts to changes and not renders in its entirety.
This is freaking awesome, and sooooo simple to reason about.