V
V
vaskadogana2018-04-20 15:15:41
Canvas
vaskadogana, 2018-04-20 15:15:41

Why is the graph not being drawn in Canvas inside a React component?

Problem: when I call the function for drawing a graph on the canvas from willRecieveProps, the graph is drawn, but when from componentDidMount, then no.
I have already checked all stages of rendering (there is data for rendering), set a delay in didMount before execution.
Everything seems to be done.
I call the same function.
But there is no graph when I zoom in, or a drag graph appears.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-04-20
@maxfarseer

zoom/drag - most likely trigger props changes, and the graph is drawn.
Make a minimal example with a call to this function and a canvas without everything else. On pure create-react-app, for example. Perhaps, if it already works for you, then you will understand what is on the list of "differences" and slowly adding / removing - find out.
If not, you will have an example that you upload to github and we will help.
It's hard to think of what could be wrong without looking at the code. Obviously, either the canvas element somehow didn’t draw when you tried to put something there, or the link simply looks not at the current canvas, but somewhere else, since you say that everything is in order with the data.
Plus, maybe some kind of bug, try a force update (a dirty option, but since there is still no repository with an example ...)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question