what does setstate do in react code example

Example 1: setstate react js

constructor(props) {
        super(props);
        this.state = {
            isActive: true,
        };
    }

    checkStatus = () => {
        this.setState({		// use this function
            'isActive' : !this.state.isActive,
        });
    }

Example 2: setstate in react

Functional Component
const [counter, setCounter] = useState(0);

setCouter(counter + 1);

Example 3: reactjs update state example

{
  hasBeenClicked: false,
  currentTheme: 'blue',
}

Example 4: reactjs update state example

{
  hasBeenClicked: false,
  currentTheme: 'bluesss',
}s