Answer the question
In order to leave comments, you need to log in
How to track props globally in React?
Task : in each component, it is necessary to style
process and return back when receiving a prop.
In Vue, I would write a global mixin that would simply keep track of the existence of a prop in the component, and pass its data to some computed, for further processing and return.
How can I implement this in React?
Answer the question
In order to leave comments, you need to log in
You could use useContext for this if you are writing functional components.
In the Provider you pass style and setStyle, in each component you do const {style, setStyle} = useContext(...). And then call setStyle(newStyle) anywhere in the component, profit. You do not need to explicitly pass props to all components, this is evil
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question