Skip to content
This repository was archived by the owner on Jul 29, 2025. It is now read-only.
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

addClass and removeClass implementation should be consistent across all components #793

@moog16

Description

@moog16

There are currently 2 different implementations of removeClass:

      removeClass: (className: string) => {
        const classList = new Set(this.state.classList);
        classList.delete(className);
        this.setState({classList});
      },

AND

      removeClass: (className: string) => {
        const {classList} = this.state;
        classList.delete(className);
        this.setState({classList});
      },

The difference being creating a new Set(). We should not be altering state directly, which is why we create new Set. addClass should also follow this pattern.

Related https://github.com/material-components/material-components-web-react/pull/792/files#r271249191

Metadata

Metadata

Assignees

No one assigned

    Labels

    Unresolved (Archived)Open and unresolved issues and PRs that were closed due to archiving the repository.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions