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
This is a more philosophical question about the API of this lib
Currently, the component depends on its effects propagating upwards by a lifecycle-ish onChange method, which usually triggers a change in state of the parent component / update store etc. However, this approach merges together the configuration of the component (scrollDelay, intervalDelay etc), with its effects (onChange), which makes it slightly confusing to grok IMO.
Inspired by React Router v4, I propose the following API
This separates concerns very nicely, and also avoids the overhead of having a situation where we have a hierarchy of parent component -> visibility sensor, and the onChange callback triggers a re-render from the parent component downwards. It helps avoid one layer of lifting state up, and is easier to read IMO.
Thoughts?
The text was updated successfully, but these errors were encountered:
This is a more philosophical question about the API of this lib
Currently, the component depends on its effects propagating upwards by a lifecycle-ish
onChange
method, which usually triggers a change in state of the parent component / update store etc. However, this approach merges together the configuration of the component (scrollDelay
,intervalDelay
etc), with its effects (onChange
), which makes it slightly confusing to grok IMO.Inspired by React Router v4, I propose the following API
This separates concerns very nicely, and also avoids the overhead of having a situation where we have a hierarchy of parent component -> visibility sensor, and the
onChange
callback triggers a re-render from the parent component downwards. It helps avoid one layer of lifting state up, and is easier to read IMO.Thoughts?
The text was updated successfully, but these errors were encountered: