- React - Home
- React - Introduction
- React - Roadmap
- React - Installation
- React - Features
- React - Advantages & Disadvantages
- React - Architecture
- React - Creating a React Application
- React - JSX
- React - Components
- React - Nested Components
- React - Using Newly Created Components
- React - Component Collection
- React - Styling
- React - Properties (props)
- React - Creating Components using Properties
- React - props Validation
- React - Constructor
- React - Component Life Cycle
- React - Event management
- React - Creating an Event−Aware Component
- React - Introduce Events in Expense Manager APP
- React - State Management
- React - State Management API
- React - Stateless Component
- React - State Management Using React Hooks
- React - Component Life Cycle Using React Hooks
- React - Layout Component
- React - Pagination
- React - Material UI
- React - Http Server
- React - Http client programming
- React - Form Programming
- React - Forms
- React - Controlled Component
- React - Uncontrolled Component
- React - Formik
- React - Conditional Rendering
- React - Lists
- React - Keys
- React - Routing
- React - Redux
- React - Animation
- React - Bootstrap
- React - Map
- React - Table
- React - Managing State Using Flux
- React - Testing
- React - CLI Commands
- React - Building and Deployment
- React - Example
- Hooks
- React - Introduction to Hooks
- React - Using useState
- React - Using useEffect
- React - Using useContext
- React - Using useRef
- React - Using useReducer
- React - Using useCallback
- React - Using useMemo
- React - Custom Hooks
- React Advanced
- React - Accessibility
- React - Code Splitting
- React - Context
- React - Error Boundaries
- React - Forwarding Refs
- React - Fragments
- React - Higher Order Components
- React - Integrating With Other Libraries
- React - Optimizing Performance
- React - Profiler API
- React - Portals
- React - React Without ES6 ECMAScript
- React - React Without JSX
- React - Reconciliation
- React - Refs and the DOM
- React - Render Props
- React - Static Type Checking
- React - Strict Mode
- React - Web Components
- Additional Concepts
- React - Date Picker
- React - Helmet
- React - Inline Style
- React - PropTypes
- React - BrowserRouter
- React - DOM
- React - Carousel
- React - Icons
- React - Form Components
- React - Reference API
- React Useful Resources
- React - Quick Guide
- React - Cheatsheet
- React - Axios CheatSheet
- React - Useful Resources
- React - Discussion
React - Expense Manager API
First, create a new expense Rest API application by following instruction from Http Client Programming -> Expense Rest API Server and start the server. The expense server will be running at http://localhost:8000.
Create a skeleton application
Open a terminal and go to your workspace.
> cd /go/to/your/workspace
Next, create a new React application using Create React App tool.
> create-react-app react-expense-app
It will a create new folder react-expense-app with startup template code.
Next, go to expense-manager folder and install the necessary library.
cd react-expense-app npm install
The npm install will install the necessary library under node_modules folder.
Delete all files under src and public folder.
Next, create a folder, components under src to include our React components. The final structure of the application will be as follows:
|-- package-lock.json |-- package.json `-- public |-- index.html `-- src |-- index.js `-- components | |-- mycom.js | |-- mycom.css
Let us create our root component, App, which will render the entire application.
Create a file, App.js under components folder and write a simple component to emit Hello World message.
import React from "react";
class App extends React.Component {
render() {
return (
<div>
<h1>Hello World!</h1>
</div>
);
}
}
export default App;
Next, create our main file, index.js under src folder and call our newly created component.
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
const container = document.getElementById('root');
const root = createRoot(container);
root.render(<App />);
Next, create a html file, index.html (under public folder), which will be our entry point of the application.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Expense App</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
Next, serve the application using npm command.
npm start
Next, open the browser and enter http://localhost:3000 in the address bar and press enter.