2017-12-14 16 views
-1

大文字と小文字などのチェック文字列が必要です.iすべての偽の初期状態があり、状態を更新するには値の入力に依存します。私は更新された状態で症例の終わりに状態を戻したい。還元状態を1つずつ更新して最後の状態に戻すにはどうすればよいですか?

const INITIAL_STATE = {lowercaseStatus:false,upperCaseEditStatus:false,allStatus:false} 
    export default (state = INITIAL_STATE, action) => { 
    switch (action.type) 
    { 
    case INPUT: 

    If(uppercase(action.payload.value)) 
    { 

    Update  upperCaseEditStatus to true 
    }  

    If(lowerCase(action.payload.value)) 
    { 

    Update  lowercaseStatus to true 
    } 

    If(other condition) 
    { 
    Upates props depends on corresponding condition 
    }  


    retrun state; 
    } 

この機能を実現する方法を教えてください。

答えて

1

あなたがこのような状態オブジェクトの不変性について...の使用、拡散作業を行うことができ、

case INPUT: 
    temp = {}; 
    temp.upperCaseEditStatus = uppercase(action.payload.value) 
    temp.lowercaseStatus = lowerCase(action.payload.value) 
    ... //Other conditions 
    return { ...state, ...temp }; 
default: 
    return state; 
関連する問題