Select to view content in your preferred language

Some of features in FeatureLayer disappear

497
3
10-26-2024 04:25 PM
Sparkles
Emerging Contributor

I have a FeatureLayer with polylines, and it has very flaky behavior, where some or all of them will intermittently no longer show when I trigger state changes in React on my page (click buttons on page, etc). I tried debugging by checking the souce._items in my FeatureLayer in the chrome console, but wasn't able to see anything strange about the data, and the visible field says "true". Does anyone know what debugging steps I could take/ what attributes in the logged FeatureLayer should I look at? Thanks!

0 Kudos
3 Replies
RamaniGanason
Regular Contributor

Is it possible to record the a short video of the issue and some code snippets how are you adding the layer to the map?

If I want to guess from the explanation above, it could be that you are re-rendering the layer/mapview when there is some changes state change. For loading a webmap/adding layer, you should do it during the initial load of the component. Eg : 

useEffect(() => {
    // Init the Map
    // Add Layer to Map
    // Load Map to View
}, []); // Empty array means will only load at the first render
0 Kudos
Sparkles
Emerging Contributor

Thanks for the response @RamaniGanason ! Yeah I do see how the layer is being rerendered when I change state on the rest of the page. I thought however that that wouldn't cause the strange behavior of some of the features intermittently not showing? I thought that it should just cause the layer to rerender (and all features to still display). Are you saying that rerendering the layer could cause that flaky behavior of some features not showing? I am working on a codepen to share. Thanks!

0 Kudos
MarkC1
by
Frequent Contributor

@Sparkles Did you ever resolve this? We're experiencing a similar sounding issue.

0 Kudos