score:0

Accepted answer

you shouldn't get an undefined, i think it is a problem with your input component. i created a codesandbox with the same use case. as you type into the input, the child component will change the state variable and the parent uses it.

it is completely fine to create a controlled child component like this.

score:0

seems like you have mis-spelled input.

in react if the first letter of any html tag is capital, then it is treated as a custom react component.

simply rename this

 <input autofocus placeholder="project name" value={projectname} onchange={({ target }) => { setprojectname(target.value) }}  />

to

<input autofocus placeholder="project name" value={projectname} onchange={({ target }) => { setprojectname(target.value) }}  />

Related Query

More Query from same tag