src/components/search-segment.js
// Reducer for the actual search.
Reducer for the actual search.
Reducer for the actual search .
function resultReducer(state, action) {
        switch (action.type) {
            case 'CLEAN_QUERY':
                return initialState
            case 'START_SEARCH':
                return {...state, loading: true, value: action.query}
            case 'FINISH_SEARCH':
                return {...state, loading: false, results: action.results}
            case 'UPDATE_SELECTION':
                return {...state, value: action.selection}
            default:
                throw new Error()
        }
    }
function resultReducer ( state , action ) { switch ( action . type ) { case 'CLEAN_QUERY' : return initialState case 'START_SEARCH' : return { ... state , loading : true , value : action . query } case 'FINISH_SEARCH' : return { ... state , loading : false , results : action . results } case 'UPDATE_SELECTION' : return { ... state , value : action . selection } default : throw new Error ( ) } }
Reducer for the actual search.
Reducer for the actual search .