initHook method

void initHook()
inherited

Initializes the hook. This method is called when the hook is created. You can override this method to ensure that the hook is properly initialized and to bind the instance to the states. This is particularly useful for setting up state dependencies or performing side effects when the hook is first created.

For example, you can use the UseEffect hook to execute a side effect when a state changes:

@override
void initHook() {
  UseEffect(
    () {
      print("Executed by state changed");
    },
    [state],
  );
}

Implementation

void initHook() {}