File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # useMap
2+
3+ 리액트 훅으로, 상태로 키-값 쌍인 맵(Map)을 관리해요. 효율적인 상태 관리를 제공하고 안정적인 액션 함수를 제공해요.
4+
5+ ## 인터페이스
6+
7+ ``` ts
8+ function useMap(initialState : MapOrEntries <K , V >): UseMapReturn <K , V >;
9+ ```
10+
11+ ### 파라미터
12+
13+ <Interface
14+ required
15+ name="initialState"
16+ type="MapOrEntries<K, V>"
17+ description="초기 맵 상태 (맵 객체 또는 키-값 쌍의 배열)"
18+ />
19+
20+ ### 반환 값
21+
22+ <Interface
23+ name=""
24+ type="UseMapReturn<K, V>"
25+ description="맵 상태와 이를 조작하는 액션을 포함한 튜플이에요"
26+ />
27+
28+ ## 예시
29+
30+ ``` tsx
31+ const [userMap, actions] = useMap <string , User >([
32+ [' user1' , { name: ' John' , age: 30 }],
33+ ]);
34+
35+ // 맵에서 값 사용하기
36+ const user1 = userMap .get (' user1' );
37+
38+ // 맵 업데이트하기
39+ actions .set (' user2' , { name: ' Jane' , age: 25 });
40+ ```
Original file line number Diff line number Diff line change 1+ # useMap
2+
3+ A React hook that manages a key-value Map as state. Provides efficient state management and stable action functions.
4+
5+ ## Interface
6+
7+ ``` ts
8+ function useMap(initialState : MapOrEntries <K , V >): UseMapReturn <K , V >;
9+ ```
10+
11+ ### Parameters
12+
13+ <Interface
14+ required
15+ name="initialState"
16+ type="MapOrEntries<K, V>"
17+ description="Initial Map state (Map object or array of key-value pairs)"
18+ />
19+
20+ ### Return Value
21+
22+ <Interface
23+ name=""
24+ type="UseMapReturn<K, V>"
25+ description="tuple containing the Map state and actions to manipulate it"
26+ />
27+
28+ ## Example
29+
30+ ```` tsx
31+ ` ` ` tsx
32+ const [userMap, actions] = useMap<string, User>([
33+ ['user1', { name: 'John', age: 30 }]
34+ ]);
35+
36+ // Using values from the Map
37+ const user1 = userMap.get('user1');
38+
39+ // Updating the Map
40+ actions.set('user2', { name: 'Jane', age: 25 });
41+ ` ` ` `
42+
43+ ` ` `
44+
45+ ```
You can’t perform that action at this time.
0 commit comments