Canvas Pottery

When Does useState Trigger a Rerender?

When using useState, the functional component gets called "whenever the state is updated". But what does that mean exactly? Does it mean whenever "set*()" gets called, or when the value itself changes?

For example, in:

      
        function Counter() {
          const [count, setCount] = useCount(0)

          function dontIncrement() {
            setState(0)
          }

          return (
            <div>
              {count}
              <button
                onClick={dontIncrement}>
                Do Nothing
              </button>
            </div>
          )
        }
      
    
The initial value of count is 0, and whenever "Do Nothing" is clicked, the value of count is set to 0. Will this trigger a render or no?

The answer is that the function will in fact, not re-render, because the value of count remains the same.