Can't type in React input text field

后端 未结 8 2277
无人共我
无人共我 2020-12-02 11:56

I\'m trying my first bit of React.js and am stumped early on... I have the code below, which renders a search form into

. B
8条回答
  •  难免孤独
    2020-12-02 12:28

    Using value={whatever} will make it so you cannot type in the input field. You should use defaultValue="Hello!".

    See https://facebook.github.io/react/docs/uncontrolled-components.html#default-values

    Also, the onchange should be onChange as @davnicwil points out.

提交回复
热议问题