This seems to happen because componentDidUpdate is not called (I think), this happens because we’re mutating the state by using trail.push(value);. To solve this we can either use concat() or something like [...trail, newItem].
Interesting links:
- Correct modification of state arrays in React.js
- ReactJS Array.push function not working in setState
- How to Add to an Array in React State using Hooks
While this seem to improve those errors on first polyline load for small datasets, it just makes it slower for real cases (which always have a lot of data). Maybe its because its creating a new array every time?