did you try access map object from state this.map.state.map?
refs should work after component is mounted
I tried this, but unfortunately it is null
componentDidMount() {
console.log(this.map.state.map)
}
strange thing if I log this.map I see state.map WAT? Still looking into this
class ReactMapboxGlCustom extends ReactMapboxGl {
componentDidMount() {
ReactMapboxGl.prototype.componentDidMount.call(this)
this.props.onMount && this.props.onMount(this.state.map) // this.state.map is null
}
}
For future googlers there is onStyleLoad which is called when map is available
<ReactMapboxGl onStyleLoad={ (map) => { ... } } />
Most helpful comment
For future googlers there is
onStyleLoadwhich is called whenmapis available