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

AddressMinimap doesn't set accessToken on initial render #499

Open
Yuripetusko opened this issue Feb 10, 2025 · 0 comments
Open

AddressMinimap doesn't set accessToken on initial render #499

Yuripetusko opened this issue Feb 10, 2025 · 0 comments

Comments

@Yuripetusko
Copy link

"@mapbox/search-js-core": "1.0.0-beta.25",
"@mapbox/search-js-react": "1.0.0-beta.25",

Can only be reproduced on deployed url (works fine on local dev server)

When passing accessToken to <AddressMinimap accessToken="..." />, and navigating to a page where Minimap is rendered, the request is made with accessToken=undefined, but works correctly on subsequent re-renders (when feature changes for example). I found a workaround by setting accessToken to a config singleton at the top of the file

config.accessToken = MAPBOX_API_TOKEN

But feels like this useEffect in mapbox react code doesn't work correctly.

 useEffect(() => {
    if (ref.current) ref.current.accessToken = accessToken;
  }, [ref.current, accessToken]);
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

1 participant