Can't type in React input text field

后端 未结 8 2215
无人共我
无人共我 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:34

    Once I ran into a similar error. Let me describe it.

    Edit.js

       // components returns edit form 
       
       function EditVideo({id}) {
       .....
       
       // onChange event listener 
        const handleChange = (e) => {
           setTextData({
               ...textData,
               [e.target.name]: e.target.value.trim()
            });
         }
      
       ....
       ...
       }
    )
    

    ImportEdit.js

       import Edit from './Edit';
       
        function ImportEdit() {
        ......
         ...
        return (
            
    ) } export default ImportEdit

    The Problem was: I was unable to use spacebar (i.e. if i press spacekey, i didn't see space input)

    The Bug: .trim()

    .trim() method was trimming all the white space i typed

    Note: Edit.js worked fine when used sepeartely without import

提交回复
热议问题