개발/React

[React] 필요한 라이브러리 설치

hr0513 2025. 2. 5. 09:28
728x90
반응형

안녕하세요, hr0513입니다!

제가 직접 사용하고 있는 라이브러리들을 소개해드리려구 해요


1. react-router-dom

npm

npm install react-router-dom

 

yarn

yarn add react-router-dom@6

 

App.js

import { Routes, Route } from "react-router-dom";
import Home from "./pages/Home";
import MainLayout from "./layouts/MainLayout";

function App() {
  return (
    <>
      <Routes>
        <Route element={<MainLayout />}>
          <Route path="/" element={<Home />} />
        </Route>
      </Routes>
    </>
  );
}

export default App;

 

index.js

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import "./index.css";
import App from "./App.jsx";

createRoot(document.getElementById("root")).render(
  <StrictMode>
    <BrowserRouter>
      <App />
    </BrowserRouter>
  </StrictMode>
);

2. react-icons

npm

npm install react-icons

 

yarn

yarn add react-icons

3. react-query

npm

npm install @tanstack/react-query

 

yarn

yarn add @tanstack/react-query

 

 

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import "./index.css";
import App from "./App.jsx";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

const queryClient = new QueryClient();

createRoot(document.getElementById("root")).render(
  <StrictMode>
    <QueryClientProvider client={queryClient}>
        <BrowserRouter>
          <App />
        </BrowserRouter>
    </QueryClientProvider>
  </StrictMode>
);

4. react-redux

npm

npm install @reduxjs/toolkit react-redux

 

yarn

yarn add @reduxjs/toolkit react-redux
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router-dom";
import "./index.css";
import App from "./App.jsx";
import { Provider } from "react-redux";
import store from "./store/store.js";

const queryClient = new QueryClient();

createRoot(document.getElementById("root")).render(
  <StrictMode>
      <Provider store={store}>
        <BrowserRouter>
          <App />
        </BrowserRouter>
      </Provider>
  </StrictMode>
);

5. styled-components

npm

npm install styled-components

 

yarn

yarn add styled-components

6. swiper

npm

npm install swiper

 

yarn

yarn add swiper

7. react-loader-spinner

npm

npm install react-loader-spinner

yarn

yarn add react-loader-spinner

8. ant design

npm

npm install antd

 

yarn

yarn add antd

 


9. react-typing-animation

npm

npm i --save react-typing-animation

 

yarn

yarn add react-type-animation

10. Recoil 설치

Recoil 설치하고 정상 작동하려면 19버전은 지원을 안해요

그래서 18버전으로 다운그레이드 해야 됩니다

yarn add react@18 react-dom@18

 

yarn

 

yarn add recoil
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import { Provider } from "react-redux";
import { store } from "./redux/store";
import { RecoilRoot } from "recoil";
import { BrowserRouter } from "react-router-dom";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
  <React.StrictMode>
    <BrowserRouter>
      <Provider store={store}>
        <RecoilRoot>
          <App />
        </RecoilRoot>
      </Provider>
    </BrowserRouter>
  </React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

직접 설치해서 멋진 웹 사이트를 만들어 보세요!

 

728x90
반응형