mapbox / mapbox/mapbox-gl-draw

Using createRoot instead of ReactDOM.render breaks "draw." callbacks

Open
#1,118 0 comments 0 reactions 0 assignees View on GitHub
auto-triaged bug
Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
8d 9h
Merged PRs (30d)
5

Description

**mapbox-gl-js version**: 2.10.0
**mapbox-gl-draw version**: 1.3.0

### Steps to Trigger Behavior

1. Create a react app with react version > 18
2. Use createRoot in your index file as instructed here: https://reactjs.org/blog/2022/03/08/react-18-upgrade-guide.html
3. Create a map with a draw MapboxDraw component.
4. Provide a callback for "draw.create"

### Expected Behavior
The callback provided to "draw.create" should be called upon drawing a polygon.

### Actual Behavior
The callback doesn't get called. Downgrading to React 17 fixes things.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in a React app using React 18 or later, createRoot in the index file, a MapboxDraw component, and a draw.create callback. Draw a polygon and verify whether the callback runs; done means the callback is invoked as expected without downgrading to React 17.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.