I'm building a little React application with the purpose of
- Able to move shapes on a canvas
- Save the state of the canvas
- Use REST API to upload/load from state
So far my application allows me to move shapes on the canvas and then save the state of the canvas by using React's useRef and then saving the value of stageRef:
const stageRef = useRef();
...
<Stage width={500} height={500} ref={stageRef}>
...(Layers and shapes)
</Stage>
This method works (in terms of saving the state) but I am unsure if using useRef is an unsafe way to handle saving state and if there is a better way.
I am using Konva for my canvas library which contains Stages, Layers, Shapes - which ultimately get saved.
Thanks for your time.