Hey, me again with timeline
[1]. Instantiating the timeline returns a dom node and I assoc it to the db so that I can use it later for adding and removing items (code in thread).
This works, but whenever I save a file, mount-root
is called again, so all panels
are rerun and I loose the current state of the timeline, since it creates another node. This is annoying for development.
Now, I’m sure the right way of solving this is wrapping the timeline in a react component that only depends on its inputs etc. (I don’t know much about react, let me know if I’m wrong) I suppose this is what this project [2] does. However, I don’t want to introduce this extra dependency to my project now.
So I’m wondering if there is a workaround for not recreating the timeline node whenever the code reload is triggered.
Thoughts?
[1]: https://visjs.github.io/vis-timeline/docs/timeline/
[2]: https://github.com/razbensimon/react-vis-timeline
Code: https://gist.github.com/Andre0991/957fb60589a6085136cc0a53efa51ca1
If react-vis-timeline
is written correctly, then it contains only the absolutely necessary code. Code, that you would have to write yourself if you want to make the component behave correctly with React and really don't want to use an extra dependency for some reason.
Also, react-vis-timeline
has a very permissive license - you can just copy its code within your project and remove all the unwanted parts, if there are any.
Sure, I can evaluate it later. I just need to know if it handles all methods used by my project.
Anyways, I suppose the answer is that the only way of having the reload issue is kinda reimplementing react-vis-timeline
, which is not worth it. But I’d be happy to roll my own minimal solution if it’s not too complicated.