Skip to content

Commit c03f81a

Browse files
committed
chore: vite 환경으로 이전 및 배포 버그 수정
1 parent 51c4324 commit c03f81a

26 files changed

+169
-25163
lines changed

.eslintrc.cjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react-hooks/recommended',
8+
],
9+
ignorePatterns: ['dist', '.eslintrc.cjs'],
10+
parser: '@typescript-eslint/parser',
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': [
14+
'warn',
15+
{ allowConstantExport: true },
16+
],
17+
},
18+
}

.gitignore

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.js
7-
8-
# testing
9-
/coverage
10-
11-
# production
12-
/build
13-
14-
# misc
15-
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
20-
1+
# Logs
2+
logs
3+
*.log
214
npm-debug.log*
225
yarn-debug.log*
236
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
249

25-
/dist
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

.idea/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.idea/external-state.iml

Lines changed: 0 additions & 12 deletions
This file was deleted.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/vcs.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.npmignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
node_modules/
2-
src/
3-
public/
1+
index.html
2+
package.json
3+
/src
44
tsconfig.json
5+
tsconfig.node.json
6+
vite.config.ts

README.md

Lines changed: 18 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,27 @@
1-
# external-state
2-
external-state is an easy and lightweight React state management library.
1+
# React + TypeScript + Vite
32

4-
[한국어](https://github.com/gabrielyoon7/external-state/blob/main/docs/readme-kr.md)
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
54

6-
### Installation
5+
Currently, two official plugins are available:
76

8-
```
9-
npm install external-store
10-
```
11-
12-
or
13-
14-
```
15-
yarn add external-store
16-
```
17-
18-
### Usage
19-
1. Creating initial state value
20-
- The initial state value is created using the `store()` function.
21-
22-
```tsx
23-
import { store } from "external-state";
24-
25-
export const countStore = store<number>(0);
26-
```
27-
28-
29-
2. Using state management hook: useExternalState
30-
- `useExternalState()` has a similar usage pattern to the react `useState()` hook.
31-
- It has the same usage pattern as recoil's useRecoilState.
32-
33-
```tsx
34-
import { useExternalState } from "external-state";
35-
36-
function Count() {
37-
const [count, setCount] = useExternalState(countStore);
38-
39-
return (
40-
<div>
41-
<div>{count}</div>
42-
<button onClick={() => setCount(count + 1)}>
43-
increase
44-
</button>
45-
</div>
46-
)
47-
}
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
489

49-
export default Count;
50-
```
51-
52-
3. Using state management hook: useSetExternalState
53-
- `useSetExternalState()` is a function used to update the state.
54-
- It has the same usage pattern as recoil's useSetRecoilState.
55-
56-
```tsx
57-
import { useSetExternalState } from "external-state";
58-
59-
function Count() {
60-
const setCount = useSetExternalState(countStore);
61-
62-
return (
63-
<div>
64-
<button onClick={() => setCount(count + 1)}>
65-
increase
66-
</button>
67-
</div>
68-
)
69-
}
70-
71-
export default Count;
72-
```
73-
74-
4. Using state management hook: useExternalValue
75-
76-
- `useExternalValue()` is a function used to subscribe the state value.
77-
- It has the same usage pattern as recoil's useRecoilValue.
78-
79-
```tsx
80-
import { useExternalValue } from "external-state";
81-
82-
function Count() {
83-
const count = useExternalValue(countStore);
84-
85-
return (
86-
<div>
87-
{count}
88-
</div>
89-
)
90-
}
91-
92-
export default Count;
93-
```
10+
## Expanding the ESLint configuration
9411

95-
5. Accessing/Modifying the store outside of React
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
9613

97-
- Once a store is created, you can use the `.getState()` and `.setState()` methods.
98-
- The `.getState()` method reads the latest state value at the time of invocation.
99-
- The `.setState()` method updates the state value.
100-
- All of this can be done directly in a vanilla environment, and even if the state is modified outside of React, all components subscribing to the store through the hook will be accurately re-rendered.
101-
- It is also possible to use `async/await`.
102-
- You can separate the logic for better reusability, as shown in the example below:
14+
- Configure the top-level `parserOptions` property like this:
10315

104-
```tsx
105-
export const countActions = {
106-
increase: () => {
107-
const prevCount = countStore.getState();
108-
countStore.setState(prevCount + 1);
109-
},
110-
decrease: () => {
111-
const prevCount = countStore.getState();
112-
countStore.setState(prevCount - 1);
113-
},
114-
increaseIfOdd: () => {
115-
const prevCount = countStore.getState();
116-
if (prevCount % 2 === 1) {
117-
countStore.setState(prevCount + 1);
118-
}
119-
},
120-
increaseAsync: async () => {
121-
const prevCount = countStore.getState();
122-
const response = await fetchCount(1)
123-
const amount = response.data;
124-
countStore.setState(prevCount + amount)
125-
}
126-
}
16+
```js
17+
parserOptions: {
18+
ecmaVersion: 'latest',
19+
sourceType: 'module',
20+
project: ['./tsconfig.json', './tsconfig.node.json'],
21+
tsconfigRootDir: __dirname,
22+
},
12723
```
12824

25+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
26+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
27+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

docs/readme-kr.md

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)