Skip to main content

useMount

React lifecycle hook that executes a function after the component is mounted

Usage

Live Editor

function Demo() {
  const [value, setValue] = useState("UnMounted");
  useMount(() => {
    setValue("Mounted");
  });
  return <div>{value}</div>;
};

Result
Loading...

API

useMount

Returns

void

Arguments

ArgumentDescriptionTypeDefaultValue
effecteffect function() => void (Required)-