1. Component Architecture
2. Setting Up Project Structure
src/
components/
pages/
services/
styles/
utils/
3. Using Material-UI
import Button from '@mui/material/Button';
function App() {
return (
<div>
<Button variant="contained">Hello World</Button>
</div>
);
}
|Learn Material for React
|Material Typography
4. Version Control with Git
5. Using React
npx create-react-app my-first-react-app
cd my-first-react-app - Start the Development Server - In the project directory, start the development server by running. This command will open a new browser window/tab with your React app running at http://localhost:3000.
npm start
import React from 'react';
import './App.css';
function App() {
return (
<div className="App">
<header className="App-header">
<h1>Hello, React!</h1>
<p>This is my first React app.</p>
</header>
</div>
);
}
export default App;
Routing enables you to have multiple different pages on your Web App. Those different pages need different routes or paths to be accessed. Therefore you need to define those routes, and pages to which they lead. Take a look into Routes React for better understanding of how this works.
- Save and View Changes
- Add a New Component - Create a New Component File - In the src folder, create a new file named MyComponent.js. - Define the New Component - Add the following code to MyComponent.js:
import React from 'react';
function MyComponent() {
return (
<div>
<h2>This is a new component!</h2>
</div>
);
}
export default MyComponent;
- Import and Use the New Component in App.js
- Open src/App.js and modify it to include MyComponent:
import React from 'react';
import './App.css';
import MyComponent from './MyComponent';
function App() {
return (
<div className="App">
<header className="App-header">
<h1>Hello, React!</h1>
<p>This is my first React app.</p>
<MyComponent />
</header>
</div>
);
}
export default App;
Hooks are very important concept in React, because they are the core mechanism of tracking the state of data and content on the web pages.
Learn about hooks: How to manage state
Most useful hooks are:
useState()
useEffect()
useNavigate()
It is always good to implement some sort of a navigation for your users. A go-to way of doing so is by implementing a Navigation Bar - Navbar. However, navigation can also be implemented for example when we want to open a profile of another user, by clicking on the user's profile picture or their name.
For implementation of Navbars: React Navbar
For implementation of Links: React Links
To provide users with a nice experience while using your App, it is necessary to add a custom name and an icon to your app.
This information is visible in your browser tab, when your app is open and running.
As visible here:
Setting up these two things helps your users find your application within all the other tabs that they have open.
To do this you should follow the next steps: