I'm developing a map functionality using ReactJS
, My app.js
file is:
import React, { Component } from 'react'; import './Map'; class App extends Component { render() { return ( <div className="App"> <Map/> </div> ); } } export default App;
The error is:
./src/App.js Line 8: 'Map' is not defined react/jsx-no-undef Search for the keywords to learn more about each error.
How can I solve this problem?
The main limitation of using jQuery in React is that jQuery manually updates the DOM. On the other hand, React has its system for making changes to the DOM. It internally determines when a React app or component should re-render. It also figures out which parts of the UI need to be updated.
Try using
import Map from './Map';
When you use import 'module'
it will just run the module as a script. This is useful when you are trying to introduce side-effects into global namespace, e. g. polyfill newer features for older/unsupported browsers.
ES6 modules are allowed to define default exports and regular exports. When you use the syntax import defaultExport from 'module'
it will import the default export of that module with alias defaultExport.
For further reading on ES6 import - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
you should do import Map from './Map'
React is just telling you it doesn't know where variable you are importing is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With