search

Home  >  Q&A  >  body text

html5 - I encountered a problem while watching the demo of react router

import React from 'react'
import { render } from 'react-dom'
import App from './modules/App'
render(<App/>, document.getElementById ('app'))
The first line means to introduce the entire js from react and name it React
The second line means to introduce the render method from react-dom
Do I understand this correctly? . Why is the path written in the third line? Can I write one or two lines directly?
The third line means to name this unnamed component App and then use it?
The URL of the demo to watch is here and the link description

阿神阿神2733 days ago719

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2017-05-31 10:42:18

    Pay attention to the package.json in the demo. It introduces many dependencies, including react and reactdom. npm i (or npm install) installs dependencies to node_modules.
    If it is ./, it means importing files under relative paths. If you directly import any path without writing it, you will import the installed modules in the node_modules directory.
    It is recommended to take a look at the knowledge of webpack and commonJS specifications

    reply
    0
  • Cancelreply