Change State - React

Make sure that when you call changeTitle the variable form.name is not undefined. If you are using react hooks and the variable form is a state or prop you can use a useEffect and change the state of title only when the variable form.name is defined

useEffect(() => {
 if(form.name){
  changeTitle(form.name);
 }
},[form.name]);