Can't type in React input text field

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

    I also have same problem and in my case I injected reducer properly but still I couldn't type in field. It turns out if you are using immutable you have to use redux-form/immutable.

    import {reducer as formReducer} from 'redux-form/immutable';
    const reducer = combineReducers{
    
        form: formReducer
    }
    import {Field, reduxForm} from 'redux-form/immutable';
    /* your component */
    

    Notice that your state should be like state->form otherwise you have to explicitly config the library also the name for state should be form. see this issue

    0 讨论(0)
  • 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 (
            <div>
                <EditVideo id={id}/>
            </div>
           )
        }
    
        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

    0 讨论(0)
提交回复
热议问题