Calling setState on the current state is always a no-op. Did you mean to change the state like $Y(!$X) instead?
Apply with the Grit CLI
grit apply calling_set_state_on_current_state
on useState $y($x)
=> $y(!$x)
BEFORE
const DilogBox = ({ params }) => { const [isOpen, setIsOpen] = useState<boolean>(false); const [columnRef, setColumnRef] = useState<HTMLElement | null>(null); return ( <Container> <Button onClick={() => { setIsOpen(isOpen) setIsOpen(isOpen) }} > Open </Button> <Button onClick={() => { setIsOpen(!isOpen) }} > Close </Button> </Container> ); };
AFTER
const DilogBox = ({ params }) => { const [isOpen, setIsOpen] = useState<boolean>(false); const [columnRef, setColumnRef] = useState<HTMLElement | null>(null); return ( <Container> <Button onClick={() => { setIsOpen(!isOpen) setIsOpen(!isOpen) }} > Open </Button> <Button onClick={() => { setIsOpen(!isOpen) }} > Close </Button> </Container> ); };