Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function routesReducer(state = initialState, action = {}) {
switch (action.type) {
// focus action is dispatched when a new screen comes into focus
case ActionConst.FOCUS:
console.log(action);
return {
...state,
scene: action.scene,
};
// ...other actions
default:
return state;
}
}
export default function routerReducer(state = initialState, action) {
switch (action.type) {
// focus action is dispatched when a new screen comes into focus
case ActionConst.FOCUS :
return {
...state,
scene: action.scene,
};
// ...other actions
default :
return state;
}
}
export default function routerReducer(state = initialState, action) {
switch (action.type) {
// focus action is dispatched when a new screen comes into focus
case ActionConst.FOCUS :
return {
...state,
scene: action.scene,
};
// ...other actions
default :
return state;
}
}
export default function routerReducer(state = initialState, action) {
switch (action.type) {
// focus action is dispatched when a new screen comes into focus
case ActionConst.FOCUS:
return {
...state,
scene: action.scene
};
// ...other actions
default:
return state;
}
}
import { createReducer } from 'redux-create-reducer';
import { ActionConst } from 'react-native-router-flux';
const initialState = {
scene: {},
};
export default createReducer(initialState, {
// focus action is dispatched when a new screen comes into focus
[ActionConst.FOCUS](state, action) {
return {
...state,
scene: action.scene,
};
},
});
routerStack: [],
eventUnit: []
}
const Actions= {}
Actions[type.REACT_NATIVE_ROUTER_FLUX_EVENT] = (state, action) => {
if (action.payload.type) {
return {
...state,
eventUnit: ArrayTool.push(state.eventUnit, {type: action.payload.type, routeName: action.payload.routeName ? action.payload.routeName : 'back', params: action.payload.params})
}
}
}
Actions[ActionConst.FOCUS] = (state, action) => { // PUSH
return {
...state,
routerStack: [action.payload.routeName, ...state.routerStack], // 入栈
eventUnit: []
}
}
Actions[type.REACT_NATIVE_ROUTER_FLUX_BACK] = (state, action) => { // POP
return {
...state,
routerStack: [...ArrayTool.shift(state.routerStack)],
eventUnit: []
}
}
Actions[type.REACT_NATIVE_ROUTER_FLUX_EVENT_CLEAR] = (state, action) => {
return (state, action) => {
if (action.type === ActionConst.FOCUS && action.scene && action.scene.initial) {
isMainScreen = true;
} else {
isMainScreen = false;
}
if (action.type === ActionConst.BACK_ACTION || action.type === ActionConst.BACK) {
DeviceEventEmitter.emit('navigatorBack');
}
return defaultReducer(state, action);
};
};
export default function reducer (state = initialState, action = {}) {
switch (action.type) {
case ActionConst.FOCUS: {
const stackDepth =
parseInt(action.scene.key.replace(action.scene.sceneKey, '').replace('_', ''))
return {
...state,
scene: action.scene,
stackDepth: stackDepth
}
}
default:
return state
}
}
export default function reducer (state = initialState, action = {}) {
switch (action.type) {
case ActionConst.FOCUS:
return { ...state, scene: action.scene }
}
return state
}
export default function reducer (state = initialState, action = {}) {
switch (action.type) {
case ActionConst.FOCUS:
return {
...state,
scene: action.scene
}
default:
return state
}
}