Skip to content

AddressMinimap doesn't set accessToken on initial render #499

Description

@Yuripetusko
"@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]);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions