react-globe.gl
react-globe.gl copied to clipboard
Change colors of arcs dynamically
Hey there, I've been looking around trying to find an example of how to change an arc's color after it's already drawn, but I can't seem to find a way on how to do that, At least not easily, I think.
Using a function or a property for arcColor, does not have any effect except throwing the following error.
Uncaught TypeError: can't access property "material", textObj is undefined
updateObj three-globe.module.js:2435
updateObjs data-joint.module.js:295
updateObjs data-joint.module.js:290
viewDigest data-joint.module.js:271
threeDigest three-globe.module.js:580
update10 three-globe.module.js:2415
digest kapsule.module.js:148
later index.js:27
three-globe.module.js:2435:8
Is there a way to change the color at all, or am I doing something wrong here? Thank you!
@EgoMaw if you pass a new value/method onto the arcColor
prop it should update the colors.
What could happen is that your memoizing the function that you pass onto arcColor
and therefore the component doesn't know it should rerender the arcs with new colors. If so, make sure your function reference actually changes when your logic does.
That was one of the first things I tried, however, the arc disappears, and that error is logged instead. So I was a bit at loss 😅