Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layers do not renderer #1016

Open
flannerybh opened this issue Nov 21, 2022 · 2 comments
Open

Layers do not renderer #1016

flannerybh opened this issue Nov 21, 2022 · 2 comments

Comments

@flannerybh
Copy link

When a map has a layer something like this:

<Layer type="symbol" id="marker" layout={{ 'icon-image': 'school-15' }}>

<Feature coordinates={[-98.978340, 42.539770]} />

</Layer>

The layer does not render, this is because commit 4926e492cef3a77e57a8cdf7594e9340d499392e changed layer.ts's UNSAFE_componentWillMount to componentDidMount. With that change, render is called before initialize. Since on the initial render, the source is not defined, source.setData(...) is not called.

If something else triggers a render, like calling setState({}), the layer will pop in.

Suggested Fix

I think creating a constructor for the Layer class and calling this.initialize() in the constructor (rather than in componentDidMount will fix this issue.

@emlyn-h
Copy link

emlyn-h commented Mar 9, 2023

This seems like a pretty big issue. Does that mean you currently can't use this lib to show data?

@flannerybh
Copy link
Author

I got around this by adding setState({}) on a short timer as I mentioned in the issue. Not ideal, but it works. I just wanted to document the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants