React, Uncaught ReferenceError: ReactDOM is not defined

前端 未结 6 855
渐次进展
渐次进展 2021-02-07 02:39

I am doing this Router tutorial.

My App.jsx file:

import React from \'react\';
import ReactDOM from \'react-dom\';
import { Router, Route, Link, browserH         


        
6条回答
  •  误落风尘
    2021-02-07 03:08

    1) install "npm install --save react-router-dom" with this command. 2) Know modify your App.jsx like this

    import React from 'react';
    import { Switch, Route, Link} from 'react-router-dom';
    class App extends React.Component {
    render() {
        return (
            
    ); } } class Header extends React.Component { render() { return (
    ); } } class Content extends React.Component { render() { return (
    ); } } class Home extends React.Component { render() { return (

    Home...

    ); } } class About extends React.Component { render() { return (

    About...

    ); } } class Contact extends React.Component { render() { return (

    Contact...

    ); } } export default App;

    4) modify your main.js like this

    import React from 'react';
    import ReactDOM from 'react-dom';
    import App from './App.jsx';
    import {HashRouter} from 'react-router-dom';
    ReactDOM.render((
    
        
    
    ), document.getElementById('app'))
    

提交回复
热议问题