Skip to content

[docs] Incorrect React useState Example on Toggle Button #43986

@barrownicholas

Description

@barrownicholas

Related page

https://mui.com/material-ui/react-toggle-button/

Kind of issue

Other

Issue description

On this example, the method of updating selected is incorrect and will cause rendering issues; it should be:

onChange={() => setSelected(selected => !selected)}

As opposed to:

onChange={() => setSelected(!selected)}

Opening this issue, and then I'll create a PR to fix it.

Here's the PR: #43987

Context

No response

Search keywords: toggle button

Metadata

Metadata

Assignees

Labels

docsImprovements or additions to the documentation.scope: toggle buttonChanges related to the toggle button.support: docs-feedbackFeedback from documentation page.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions