Media queries with effector
Zero Bias
Effector Core TeamHi!
In this article I will show how to make react component which will work like this
Media queries itself could been handled in such way:
But how this could been used in react components? (actually, we’ll make more universal thing, which can be used in various ways)
Effector can reacts on media queries changes and provide current query state as store
orientationChange
is just a function
We can rewrite it for reuse with any query
For my device currently it prints is small screen? false
Lets make it single store, thereby creating common base to connect it to view framework further
Now we could connect it to view framework, react, using effector-react
library
Done!
It support nesting out from a box