Answer the question
In order to leave comments, you need to log in
How to make Responsive svg (D3.js) correctly?
Hello everyone, tell me, please, how to make Responsive svg correctly?
Below is my implementation, but I think there is a better approach.
https://codepen.io/gsdev99/pen/QWwmeKp
Answer the question
In order to leave comments, you need to log in
On resize you don't need throttle, remove it and it will work more clearly.
With such a thing, you will end badly if you suddenly have some kind of state in the component. And you have it. Because every time you change the state, you will add an additional handler resize
to window
. Either delete the previous handlers somehow, or do it differently, for example, by adding a flag that will signal that the handler is already hanging, and you don’t need to add it again.
useEffect(() => {
window.addEventListener('resize', onResize)
}, [])
store
one mobx
, where the width will be updated, and the component will be updated when necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question