search.js 681 Bytes
const CHANGE = 'search/CHANGE';
const SUBMIT = 'search/SUBMIT';

export const change = (text) => ({ 
    type: CHANGE,
    text,
})

export const submit = (text) => ({ 
    type: CHANGE,
    text,
})

const initialState = {
    query: '',
    searchResult:{},
};
   
export default ToggleLoading = (state = initialState, action) => {
    switch (action.type) {
        case CHANGE:
            return {...state, query: action.text};
        case SUBMIT:
            return {...state, query: ''}
        default:
            return state;
    }
}

submit=()=>{
    this.props.toggleLoading();
    setTimeout(()=>{this.props.toggleLoading()},1000);
    this.setState({query:''});
}