Skip to content

Dynamic changes of className are not reflected upon rerender #50

@Muchaszewski

Description

@Muchaszewski

When the style is dynamic with the use of the if statement directly in the render method, its changes are not reflected upon state change.

Example:

function Foo() {
  const [state, setState] = useState('none');

    return (
      <button className={(state !== 'game' ? ' class1' : ' class2')}
        onClick={() => (state !== 'game' ? setState('game') : setState('none'))}>
          Test
      </button>
    );
}

Actual result
Nothing happens

Expected result
Assuming class1 should set scale to 125 and class2 should set scale to 100
https://user-images.githubusercontent.com/5092066/165640284-ad62f2dc-0217-46c2-8751-60ed89688658.mp4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions