Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Create new reacta app:
- In terminal execute: "npx create-react-app ." (with "." you reffer the current folder for main project dir)
- Then cd the app dir and execute: "npm start"
- ------------------------------------------------------------------------------------------
- Router
- 1.npm i react-router-dom
- import { BrowserRouter } from 'react-router-dom';
- wrap our "<App />" with "<BrowserRouter>":
- <BrowserRouter>
- <App />
- </BrowserRouter>
- ------------------------------------------------------------------------------------------
- 2.import { Routes,Route} from 'react-router-dom';
- syntacs:
- <Routes>
- <Route path="/" element={<Home />} />
- </Routes>
- ------------------------------------------------------------------------------------------
- 3.import { Link } from 'react-router-dom';
- example for navbar(href #):
- <Link className="home" to="/">
- This is home page!
- </Link>
- <NavLink></NavLink> -> when u want to use .isActive property! can be mixed Link & NavLink
- ------------------------------------------------------------------------------------------
- FOR DEPLOY REACT APP IN FIREBASE:
- 0. npm -build
- 1. nmp i -g firebase-tools
- 2. npm -init
- 3. type enter , choose option: Hosting: configure files for Firebase hosting and ....
- 4. choose existing project and find it...
- 5. use "build" for public dir.
- 6. configure as a SPA app (rewrite all urls to /index.html) - YES
- 7. git continue - NO
- 8. override - NO
- 9. execute - firebase deploy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement