![]() |
VOOZH | about |
React uses Hooks and data fetching libraries to efficiently load and maintain application data.
Step 1: Create a React.js application by using this command.
npx create-react-app my-appStep 2: Navigate to the project directory.
cd my-appStep 3: Install Tailwind CSS.
npm install -D tailwindcss
npx tailwindcss init
Step 4: Install the necessary packages/libraries in your project using the following commands.
npm install axiosProject Structure
👁 Screenshot-2024-03-20-120035
The updated dependencies in package.json file will look like:
"dependencies": {
"@apollo/client": "^3.9.6",
"axios": "^1.6.7",
"graphql": "^16.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^9.0.1",
"react-query": "^3.39.3",
"remark-gfm": "^4.0.0",
"swr": "^2.2.5"
}
}
The Fetch API allows React applications to retrieve data asynchronously and manage it using built-in React Hooks.
Output:
👁 Screenshot-2024-03-18-111913
Axios is a popular library used in React to simplify HTTP requests and response handling.
Install Axio:
npm install axiosUse you own API to test in place of url.
Output:
Data fetching libraries like React Query provide an efficient way to handle server data in React applications.
Install React Query:
npm install react-queryOutput:
👁 Screenshot-2024-03-20-114108
SWR is a React data fetching library designed for efficient and consistent data handling.
Install SWR:
npm install swrOutput:
GraphQL APIs enable flexible and efficient data fetching for modern web applications.
Install GraphQL:
npm install @apollo/client graphqlOutput: