03 Setup - biswajitsundara/react GitHub Wiki
The best way to create a react app is using the create-react-app command
- Use the command
npx create-react-app hello-world
- npx is a package runner that gets downloaded along with npm.
- If we want to create using npm then follow below two steps:
- First install the create-react app globally
npm install create-react-app -g
- Second use the command
create-react-app <project-name>
- First install the create-react app globally
Go to App.js
and edit the paragraph <p>Hello World</p>
- Use the command
npm start
- we will see the app
http://localhost:3000/
These are not specific to react and not mandatory however these VS code extensions will help
- Prettier (Preferences -> Settings -> Default formatter -> Set Prettier)
- Material Icon Theme
Install React developer tools browser extension - https://reactjs.org/link/react-devtools
- Currently the react-app generates project in react-18 however the APIs are still pointing to 17 version
- So make the below changes
- Replace the
react-dom
import withimport {createRoot} from 'react-dom/client'
- Replace the
ReactDOM.render
with the below.
const container = document.getElementById('root'); const root = createRoot(container); root.render(<App />);