Uncaught TypeError: Cannot read property '0' of undefined
See original GitHub issueNo matter what I do, I can not get the map to actually render. The box itself renders, but is empty and this error mapbox-gl.js?31ef:295 Uncaught TypeError: Cannot read property '0' of undefined
appears every time i move my mouse around where the map should be. The cursor changes, so the map box is there, just empty. Below is the component that renders it:
import React from "react"
import cssModules from "react-css-modules"
import style from "./style.css"
import { connect } from 'react-redux'
import ReactMapboxGl, { Layer, Feature } from "react-mapbox-gl"
const config = {
containerStyle: {height: "100vh", width: "100vw"},
accessToken: "....",
style: "mapbox://styles/mapbox/streets-v9"
};
export class Map extends React.Component {
render() {
return (
<div>
<h1>Hello</h1>
<ReactMapboxGl
style={config.style}
accessToken={config.accessToken}
containerStyle={config.containerStyle}
/>
</div>
)
}
}
const mapStateToProps = state => {
return {
user: state.user
}
}
export default connect(mapStateToProps)(cssModules(Map, style))
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
How To Fix Cannot read Property '0' of Undefined in JS
The Solution · Ensure you are using the correct variable · Perform a simple check on your variable before using it to make...
Read more >How to Prevent the Error: Cannot Read Property '0' of Undefined
If a property of an object is an array, it's possible to accidentally misspell the key or try to access the array through...
Read more >TypeError: Cannot read Property '0' of Undefined in JS
The "Cannot read property '0' of undefined" error occurs when trying to access the 0th index in a variable that stores an undefined...
Read more >Javascript Uncaught TypeError: Cannot read property '0' of ...
Javascript Uncaught TypeError: Cannot read property '0' of undefined ; If you want to find a letter in array, then (words.indexOf(letter) > 0) ......
Read more >Fix: Cannot Read Property '0' of Undefined - Coding Beauty
The “cannot read property '0' of undefined” error occurs when you try to access the 0 index of an array-like variable, but the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Should be fixed with the version 0.9.3 😃
@alex3165 it’s a company project so most likely not sorry. I can probably add in the webpack and package.json file though if that helps? I’ll have to add them when I get home.
On a side, is there any other dependencies I need to get this working? I reduced the london example to pretty much the exact same lines of code and replicated the webpack file from the example and it works there. I can’t figure out what the difference between the two is.