Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/core/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,7 @@ function Component() {
## 6.1.6(Nov 21, 2025)

- fix(createStorage): use `useLatest` to avoid unnecessary re-renders and simplify dependency arrays

## 6.1.8(Dec 2025)

- fix(useMap): fix type parameter support by moving generics into function signature, now `useMap<string, number>()` works correctly
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@reactuses/core",
"version": "6.1.7",
"version": "6.1.8",
"license": "Unlicense",
"homepage": "https://www.reactuse.com/",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/useMap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const useMap: UseMap = <K, V>(
initialValue?: Map<K, V> | readonly (readonly [K, V])[] | (() => Map<K, V> | readonly (readonly [K, V])[]),
) => {
// avoid exec init code every render
const initFunc = () => {
const initFunc = (): Map<K, V> => {
if (typeof initialValue === 'function') {
const result = initialValue()
return result instanceof Map ? new Map(result) : new Map(result)
Expand All @@ -23,7 +23,7 @@ export const useMap: UseMap = <K, V>(
return new Map<K, V>()
}

const [map, setMap] = useState(initFunc)
const [map, setMap] = useState<Map<K, V>>(initFunc)

const set = useEvent((key: K, value: V) => {
setMap(prevMap => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/useMap/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* - reset: 將 map 重置為其初始狀態的函數。
* - size: map 的當前大小。
*/
export type UseMap<K = any, V = any> = (
export type UseMap = <K = any, V = any>(
/**
* @zh 初始值,可以为 Map 实例、数组或者一个初始化的函数
* @zh-Hant 初始值,可以為 Map 實例、數組或者一個初始化的函數
Expand Down
4 changes: 4 additions & 0 deletions packages/website-docusaurus/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,7 @@ function Component() {
## 6.1.6(Nov 21, 2025)

- fix(createStorage): use `useLatest` to avoid unnecessary re-renders and simplify dependency arrays

## 6.1.8(Dec 2025)

- fix(useMap): fix type parameter support by moving generics into function signature, now `useMap<string, number>()` works correctly