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

fix: update Map event listeners on prop changes #349

Merged
merged 1 commit into from
Nov 10, 2021
Merged

fix: update Map event listeners on prop changes #349

merged 1 commit into from
Nov 10, 2021

Conversation

chwallen
Copy link
Contributor

@chwallen chwallen commented Oct 20, 2021

When updating the event listener props, the MapGL component does not propagate these changes to the underlying Mapbox instance. This makes it impossible to use state inside, for example, the onClick event handler as it will be bound to the first render. It also makes it impossible to remove event handlers dynamically.

This PR updates any event listeners that has changed in a similar way to how componentDidMount applies the initial listeners.

Fixes #324

@chwallen
Copy link
Contributor Author

@stepankuzmin Any chance that you have time to take a look at this PR?

@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #349 (5422655) into master (1290665) will decrease coverage by 1.35%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #349      +/-   ##
==========================================
- Coverage   99.47%   98.12%   -1.36%     
==========================================
  Files          26       26              
  Lines         573      587      +14     
  Branches      126      131       +5     
==========================================
+ Hits          570      576       +6     
- Misses          3        7       +4     
- Partials        0        4       +4     
Impacted Files Coverage Δ
src/components/MapGL/index.js 91.83% <42.85%> (-8.17%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1290665...5422655. Read the comment docs.

Copy link
Member

@stepankuzmin stepankuzmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @chwallen,

Thanks for the contribution! Sorry for the delayed response

src/components/MapGL/index.js Outdated Show resolved Hide resolved
@stepankuzmin
Copy link
Member

Thanks for the contribution, @chwallen!

@stepankuzmin stepankuzmin merged commit 95ebe0a into urbica:master Nov 10, 2021
@chwallen chwallen deleted the update-map-event-listeners branch November 10, 2021 11:15
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

Successfully merging this pull request may close these issues.

Map Component's onClick props do not update
2 participants