Reducer Concept - seowonintech/react-native-todo-list GitHub Wiki

Todo List๋ฅผ ์ฒ˜์Œ ์‹œ์ž‘ํ•˜๋ฉด์„œ ๋งŒ๋‚œ ์žฅ์• ๋ฌผ

kang

import { combineReducers } from 'react-redux';
import * as ActionTypes from '../actions/ActionTypes';

const todos = (state = {}, action) => {
    switch ( action.type ) {
        case ActionTypes.ADD_TODO:
            return {
                // ...state,
                // {
                //     [],
                // },
                // ...state,
                [
                    ...state.todos,
                    {
                        id,
                        text
                    }
                ]
                [{},{},{}]
            };
        case ActionTypes.REMOVE_TODO:
            return filter(t => {});
        default:
            return state;
    }
}

const todoApp = combineReducers({
    todos
});

export default todoApp;

Hyeon

import { combineReducers } from 'react-redux';
import * as ActionTypes from '../actions/ActionTypes';

const todos = (state = {}, action) => {
    switch ( action.type ) {
        case ActionTypes.ADD_TODO:
            return {
                // ...state,
                // {
                //     [],
                // },
                // ...state,
                ...state,
                [
                    {
                        id: state.id++,
                        text: action.text
                    }
                ]
                [{},{}], [{}]
            };
        case ActionTypes.REMOVE_TODO:
            return filter(t => {});
        default:
            return state;
    }
}

const todoApp = combineReducers({
    todos
});

export default todoApp;
โš ๏ธ **GitHub.com Fallback** โš ๏ธ