I'm using this for my portfolio as a dark/light mode toggle. Functionally; it works great, however, there's a slight issue with how it interacts with my theme toggling plugin.
I'm using it as part of a render prop which I believe is leading to the switch being a tad delayed to update as it's dependent on the theme value from said render prop. You can visit my portfolio to see this in effect. If dark mode is enabled, switching pages will cause the switch to flicker into the unchecked state for a frame or two before returning to the checked state.
I forked your code and tried to fix this with shouldldComponentUpdate() but didn't seem to work too nicely so I wanted to put this out there and see if you'd experienced this issue before and if this could be rectified in future.
Hey there.
I'm using this for my portfolio as a dark/light mode toggle. Functionally; it works great, however, there's a slight issue with how it interacts with my theme toggling plugin.
I'm using it as part of a render prop which I believe is leading to the switch being a tad delayed to update as it's dependent on the
theme
value from said render prop. You can visit my portfolio to see this in effect. If dark mode is enabled, switching pages will cause the switch to flicker into theunchecked
state for a frame or two before returning to thechecked
state.I forked your code and tried to fix this with
shouldldComponentUpdate()
but didn't seem to work too nicely so I wanted to put this out there and see if you'd experienced this issue before and if this could be rectified in future.