Core React Dependencies

React dependencies can be categorized into core dependencies, state management, routing, styling, data fetching, utility libraries, and build tools. Below is a breakdown with explanations and examples.
1. Core Dependencies
These are the essential dependencies for a React project.
πΉ React (react
)
-
The main library for building UI components.
-
Example:
import React from 'react'; function App() { return <h1>Hello, React!</h1>; } export default App;
πΉ React DOM (react-dom
)
-
Used for rendering components to the browser.
-
Example:
import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; ReactDOM.createRoot(document.getElementById('root')).render(<App />);
2. State Management Dependencies
These help manage the global state of your app.
πΉ Redux (@reduxjs/toolkit
, react-redux
)
-
A centralized state management tool.
-
Example:
import { configureStore } from '@reduxjs/toolkit'; import { Provider, useDispatch, useSelector } from 'react-redux'; const store = configureStore({ reducer: {} }); function App() { return ( <Provider store={store}> <h1>Redux App</h1> </Provider> ); } export default App;
πΉ Zustand
-
Lightweight alternative to Redux.
-
Example:
import create from 'zustand'; const useStore = create((set) => ({ count: 0, increment: () => set((state) => ({ count: state.count + 1 })), })); function Counter() { const { count, increment } = useStore(); return ( <div> <p>Count: {count}</p> <button onClick={increment}>Increment</button> </div> ); }
3. Routing Dependencies
These handle navigation in React apps.
πΉ React Router (react-router-dom
)
-
Enables client-side navigation.
-
Example:
import { BrowserRouter, Routes, Route, Link } from 'react-router-dom'; function Home() { return <h1>Home Page</h1>; } function About() { return <h1>About Page</h1>; } function App() { return ( <BrowserRouter> <nav> <Link to="/">Home</Link> <Link to="/about">About</Link> </nav> <Routes> <Route path="/" element={<Home />} /> <Route path="/about" element={<About />} /> </Routes> </BrowserRouter> ); } export default App;
4. Styling Dependencies
Used for styling components.
πΉ Styled Components (styled-components
)
-
Allows styling with tagged template literals.
-
Example:
import styled from 'styled-components'; const Button = styled.button` background-color: blue; color: white; padding: 10px; border-radius: 5px; `; function App() { return <Button>Click Me</Button>; }
πΉ Tailwind CSS
-
Utility-first CSS framework.
-
Example:
function App() { return <button className="bg-blue-500 text-white p-2 rounded">Click Me</button>; }
5. Data Fetching Dependencies
These help fetch and manage API data.
πΉ Axios (axios
)
-
Used for making HTTP requests.
-
Example:
import { useEffect, useState } from 'react'; import axios from 'axios'; function App() { const [data, setData] = useState([]); useEffect(() => { axios.get('https://jsonplaceholder.typicode.com/posts') .then(response => setData(response.data)); }, []); return ( <ul> {data.map(post => <li key={post.id}>{post.title}</li>)} </ul> ); }
πΉ React Query (@tanstack/react-query
)
-
Handles caching and background fetching.
-
Example:
import { useQuery } from '@tanstack/react-query'; import axios from 'axios'; function fetchPosts() { return axios.get('https://jsonplaceholder.typicode.com/posts').then(res => res.data); } function App() { const { data, error, isLoading } = useQuery(['posts'], fetchPosts); if (isLoading) return <p>Loading...</p>; if (error) return <p>Error fetching data</p>; return ( <ul> {data.map(post => <li key={post.id}>{post.title}</li>)} </ul> ); }
6. Utility Dependencies
Useful for various functions in React apps.
πΉ Lodash (lodash
)
-
Provides utility functions.
-
Example:
import _ from 'lodash'; const numbers = [1, 2, 3, 4, 5]; const doubled = _.map(numbers, (num) => num * 2); console.log(doubled); // [2, 4, 6, 8, 10]
πΉ Moment.js (moment
)
-
Used for date formatting.
-
Example:
import moment from 'moment'; function App() { return <p>{moment().format('MMMM Do YYYY, h:mm:ss a')}</p>; }
7. Build and Testing Dependencies
These assist in development and testing.
πΉ Webpack (webpack
)
-
A module bundler for React.
-
Example config (
webpack.config.js
):module.exports = { entry: './src/index.js', output: { filename: 'bundle.js', }, mode: 'development', };
πΉ Babel (@babel/preset-react
)
-
Transpiles JSX into JavaScript.
-
Example
.babelrc
:{ "presets": ["@babel/preset-react"] }
πΉ Jest (jest
)
-
A JavaScript testing framework.
-
Example test:
test('adds 1 + 2 to equal 3', () => { expect(1 + 2).toBe(3); });
πΉ React Testing Library (@testing-library/react
)
-
Used for testing React components.
-
Example:
import { render, screen } from '@testing-library/react'; import App from './App'; test('renders Hello, React!', () => { render(<App />); expect(screen.getByText('Hello, React!')).toBeInTheDocument(); });
π Key Points
β
React (react
) and React DOM (react-dom
) are core dependencies.
β
Redux, Zustand, and React Query help manage state.
β
React Router is essential for navigation.
β
Styled Components and Tailwind CSS handle styling.
β
Axios and React Query are used for fetching data.
β
Lodash and Moment.js are utility libraries.
β
Webpack, Babel, and Jest are crucial for development and testing.
Would you like more details on any of these? π
- Artificial Intelligence (AI)
- Cybersecurity
- Blockchain & Cryptocurrencies
- Internet of Things
- Cloud Computing
- Big Data & Analytics
- Virtual Reality
- 5G & Future Connectivity
- Robotics & Automation
- Software Development & Programming
- Tech Hardware & Devices
- Tech in Healthcare
- Tech in Business
- Gaming Technologies
- Tech in Education
- Machine Learning (ML)
- Blogging
- Affiliate Marketing
- Make Money
- Digital Marketing
- Product Review
- Social Media
- Excel
- Graphics design
- Freelancing/Consulting
- FinTech (Financial Technology)
- E-commerce and Digital Marketing
- Business
- Sport
- Self Development
- Tips to Success
- Video Editing
- Photo Editing
- Website Promotion
- YouTube
- Lifestyle
- Health
- Computer
- Phone
- Music
- Causes
- Networking