Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React JS Error: is not defined react/jsx-no-undef

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?

like image 254
Sarvesh Kulkarni Avatar asked Jun 08 '17 17:06

Sarvesh Kulkarni


People also ask

Can we use jQuery in react JS?

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.


Video Answer


2 Answers

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

like image 65
shawon191 Avatar answered Sep 18 '22 14:09

shawon191


you should do import Map from './Map' React is just telling you it doesn't know where variable you are importing is.

like image 33
Demon Avatar answered Sep 19 '22 14:09

Demon