2016-09-09 5 views
0

redux-forms에 문제가 있습니다. 양식이 제출되면 데이터 오브젝트는 비어 있습니다. 입력 및 제출 버튼 만 있습니다. 여기에 코드가 있으며 내가 잘못하고있는 것을 이해할 수 없습니다. 검색보기에서Redux-Forms 제출 데이터가 비어 있습니다.

:

render() { 
     const {submitSearchForm} = this.props; 

     return (
      <div> 
       <SearchForm onSubmit={submitSearchForm}/> 
      </div> 
     ); 
    } 

그리고 검색 형태로

:

renderTextField = ({input, placeholder, leftIcon, rightIcon, clickableIcon, width}) => { 

    return <TextField placeholder={placeholder} 
         leftIcon={leftIcon} 
         rightIcon={rightIcon} 
         clickableIcon={clickableIcon} 
         width={width} 
         {...input}/>; 
}; 

render() { 
    const {handleSubmit, fields} = this.props; 

    return (
     <div className="row"> 
      <form onSubmit={handleSubmit}> 

       <Field name="searchText" 
         component={this.renderTextField} 
         placeholder="Enter title and/or skills" 
         leftIcon="icon-search" 
         width={424} 
         field={fields.searchText}/> 

       <Button type="default" 
         label="go" 
         size="medium" 
         isSubmitButton={true}/> 
      </form> 
     </div> 
    ); 
} 

을 그리고 이것은 내가 SearchForm와 reduxForms을 연결하는 방법은 다음과 같습니다에 의해 모든 것을 확인 후

const reduxSearchForm = reduxForm({ 
    form: "Search", 
    fields: ["searchText"] 
}); 

export default(reduxSearchForm(SearchForm)); 
+0

아마도 renderTextField 함수를 Field 구성 요소의 소품으로 전달할 때 필요합니다. "this.renderTextField()" – zebrasinpyjamas

+0

감속기에 'form'상태를 넣으시겠습니까? –

답변

0

설명서에서, 나는이 문제가 감속기를 결합 할 때라는 것을 알았습니다. formReducer를 양식에 매핑하는 것이 매우 중요합니다. 여기에 있습니다 :

export const reducer = combineReducers({ 
    form: formReducer, 
    search 
}); 
관련 문제