Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

useMap's set() should not re-render when setting a key to the same value it's currently set to #1655

Open
Open
useMap's set() should not re-render when setting a key to the same value it's currently set to#1655

Description

What is the current behavior?

">const [count, setCount] = useState(0)
const map = useMap([['count', 0]])

console.log('rerender')

return <>
<button type="button" onClick={() => setCount(0)}>Click statebutton>
<button type="button" onClick={() => map.set('count', 0)}>Click mapbutton>
>

Clicking on the "Click state" button multiple times in a row shows "rerender" only once in the console, whereas clicking on the "Click map" button shows it for every click.

Steps to Reproduce

See above.

What is the expected behavior?

It should behave like useState().

Environment Details

  • @react-hookz/web version: 25.1.1
  • react version: 18.3.21
  • react-dom version: 18.3.7
  • typescript version: -
  • OS: macOS
  • Browser: Chrome, Safari, and Firefox
  • Did this work in previous versions? I don't know

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions