0

I have a controlled input that should not update when I type. I have stripped the component down to a basic <input/> to mitigate any side effects but it still allows me to edit the value.

const myComponent = () => {
   const text = 'Hello';
   return(
      <input value={text}/>
   )
}

I expect the value to always be Hello even when attempting to type in the input, but this is not the case. When I had other components that changed the state, the input would reset back to Hello, but only after a render was triggered by another state change. Any ideas what could be happening here? I would include a Codepen, but the code works as expected (no text change allowed) in other places outside my Next.js app

wdhilliard
  • 135
  • 11

1 Answers1

0
  <input value={text} disabled/>
visizky
  • 701
  • 1
  • 8
  • 27