Comments (5)
An attempt. IMO it would be better to add a basic-with-hooks
example rather than update every example to use hooks. Perhaps I'm just not comfortable enough with hooks yet, but the class examples feel more approachable 🤷♂️
Notes:
- Using a prop as a default value in an initialization hook seems to require wrapping in useRef()?
- There is probably a way to do the tooltip example with portals--didn't look too far into it.
Dan Abramov has an interesting post about "Making setInterval Declarative with React Hooks"; perhaps mapbox-gl-js could be made more declarative with custom hooks for initializing a map, updating mapStyle...
from mapbox-react-examples.
@bryik Finding this was very helpful! I initially went down the path of trying to use const map = React.useMemo(...)
for a few minutes before I checked the internet and found this, and of course you're right that we need to useState
instead because we need to have the map container ref.
from mapbox-react-examples.
Here's my take on hooks with mapbox-gl: https://dev.to/justincy/using-mapbox-gl-in-react-d2n
from mapbox-react-examples.
Another attempt for the basic and the tooltip example.
from mapbox-react-examples.
Closed by #11!
from mapbox-react-examples.
Related Issues (14)
- advantage of using react wrappers with mapbox gl? HOT 1
- The images in the blog are broken HOT 2
- mapbox-gl-js 2.0 doesn't work with react HOT 1
- Adding Marker Example To The Repo HOT 3
- Unable to use mapbox-gl with webpack. HOT 1
- examples do not run under WSL2 linux with NodeJS 16
- In the markers custom example my markers are not accurate and move all over the screen HOT 1
- use React to unmount tooltip, not innerHTML
- Update examples with `ReactDOM.render()` for React 18 HOT 3
- Where to add idle event in the react HOT 6
- paint.fill-color: color expected, array found in the react HOT 1
- css reference not found HOT 2
- TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createRef is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-react-examples.