2017-02-14 1 views
2

현재 redux-form을 사용하고 있으며 이제 reduxForm 구성 요소를 redux 스토리지에 연결해야합니다. 그래서, 문서보고 내가 뭔가를해야 할 :클래스 지정에서 반응

// Decorate with reduxForm(). It will read the initialValues prop provided by connect() 
InitializeFromStateForm = reduxForm({ 
    form: 'initializeFromState' // a unique identifier for this form 
})(InitializeFromStateForm) 

// You have to connect() to any reducers that you wish to connect to yourself 
InitializeFromStateForm = connect(
    state => ({ 
    initialValues: state.account.data // pull initial values from account reducer 
    }), 
    { load: loadAccount }    // bind account loading action creator 
)(InitializeFromStateForm) 

export default InitializeFromStateForm 

내가 eslint 나에게 오류주고, 내 구성 요소에 그런 일을했지만 :

no-class-asign

내가 이것을 사용하지 않아야을 redux-form과 함께 사용하기위한 규칙이 있거나 이런 종류의 것을 관리하는 방법이 있습니까?

+1

클래스 선언을 사용하는 대신 클래스 식을 사용할 수 있다고 생각합니다. 'let InitializeFromStateForm = class React.Compeont {class}'. 그러나 궁극적으로 그것은 당신에게 달려 있습니다. ESLint를 사용하면 코드 기반의 규칙을 제어 할 수 있습니다. "클래스 이름"에 새 값을 할당하는 것이 좋으면 규칙을 비활성화하십시오. –

+0

글쎄, 내 머리 속에서'eslint'에 동의하지만, 앞으로 나에게 어떤 문제 나 버그를 가져다 줄까? 내 말은, 지금은 일하고 있지만, 미래에 대해서는 아무도 모른다. – FacundoGFlores

답변

5

정말로 수업을 재할 필요가 없습니다. 왜 이런 식으로하지 마십시오

// Decorate with reduxForm(). It will read the initialValues prop provided by connect() 
const reduxFormDecorator = reduxForm({ 
    form: 'initializeFromState' // a unique identifier for this form 
}); 

const reduxConnector = connect(
    state => ({ 
    initialValues: state.account.data // pull initial values from account reducer 
    }), 
    { load: loadAccount }    // bind account loading action creator 
); 

export default reduxConnector(reduxFormDecorator(InitializeFromStateForm));