AddressMinimap doesn't set accessToken on initial render
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 768
- Forks
- 191
- PR merge metrics
- No merged PRs in 30d
Description
"@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]);
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing AddressMinimap and the shown useEffect that assigns accessToken to ref.current, then reproduce the initial navigation on a deployed URL rather than the local dev server. Done means the first request after rendering AddressMinimap includes the passed accessToken, without relying on the config singleton workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100