Answer the question
In order to leave comments, you need to log in
How to divide a component into areas of responsibility without inheritance?
Good afternoon, there is 1 complex component - working with canvas.
Now the component is a huge combine, which is responsible for:
1. Drawing on the canvas
2. Scaling and recalculating the canvas
3. Implements the event emitter interface (subscribing and dispatching events)
Obviously, maintaining this fat component class is difficult.
It is necessary to break it down into smaller areas of responsibility, at least 3.
Usually I would break these classes and use inheritance, but inheritance is not accepted in React.
A fly in the ointment is added by the fact that this is a ContextProvider (a wrapper over MyContext.Provider for managing the contents of the context), this is necessary so that any child component can manage the canvas, draw, scale, subscribe or dispatch an event
Please tell me how competently everything share what to do with it?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question