diff --git a/README.md b/README.md index a00d0dd..b0d2eae 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,15 @@ -# React + TypeScript + Vite +## State bình thường +-> nhưng nó lớn +-> nó dùng ở rất nhiều nơi -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. +=> thì cần dùng tới store stagment +=> Redux Toolkit => để tạo và quản lý store stagment -Currently, two official plugins are available: - -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) - -## React Compiler - -The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information. - -Note: This will impact Vite dev & build performances. - -## Expanding the ESLint configuration - -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: - -```js -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - - // Remove tseslint.configs.recommended and replace with this - tseslint.configs.recommendedTypeChecked, - // Alternatively, use this for stricter rules - tseslint.configs.strictTypeChecked, - // Optionally, add this for stylistic rules - tseslint.configs.stylisticTypeChecked, - - // Other configs... - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) - -``` - -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: - -```js -// eslint.config.js -import reactX from 'eslint-plugin-react-x' -import reactDom from 'eslint-plugin-react-dom' - -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - // Enable lint rules for React - reactX.configs['recommended-typescript'], - // Enable lint rules for React DOM - reactDom.configs.recommended, - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) - -``` +1. Cần tạo ra state gốc +2. Từ state gốc ta tạo ra Slice +3. Từ slice ta lấy được reducer function (để tạo ra store) & actions (để dùng cho dispatch) +4. Dùng configureStore -> kết hợp các reducer để tạo thành 1 store +5. Export Store và Type của nó ra để dùng +6. Tìm nơi lớn nhất trong dự án bao bọc bởi component Provider -> props store vừa tạo vào Provider đó +7. Ở các nơi muốn dùng store ta sử dụng useSelector để lấy +8. Ở các ơi muốn gọi tới các action (tức các case ở trong slice reducers) -> thì dùng useDispatch \ No newline at end of file