reduxer import in react code example
Example 1: react/redux reducers sintaxe
const reduxSinaxe = (state = [], action) => {
switch (action.type) {
case "@smthg/ACTION":
const { anyConst } = action;
return [...state, anyConst];
default:
return state;
}
};
export default reduxSinaxe;
Example 2: react native reducer example
import { combineReducers } from 'redux';
const INITIAL_STATE = {
current: [],
possible: [
'Alice',
'Bob',
'Sammy',
],
};
const friendsReducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
default:
return state
}
};
export default combineReducers({
friends: friendsReducer
});