mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-29 04:45:19 +08:00
fix: don't handle replace if screen to replace with isn't present
fixes #193
This commit is contained in:
@@ -22,6 +22,10 @@ const BaseRouter = {
|
||||
|
||||
const { name, key, params } = action.payload;
|
||||
|
||||
if (!state.routeNames.includes(name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
routes: state.routes.map((route, i) =>
|
||||
|
||||
@@ -65,6 +65,15 @@ it("doesn't handle REPLACE if source key isn't present", () => {
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
|
||||
it("doesn't handle REPLACE if screen to replace with isn't present", () => {
|
||||
const result = BaseRouter.getStateForAction(
|
||||
STATE,
|
||||
CommonActions.replace('nonexistent', { answer: 42 })
|
||||
);
|
||||
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
|
||||
it('sets params for the focused screen with SET_PARAMS', () => {
|
||||
const result = BaseRouter.getStateForAction(
|
||||
STATE,
|
||||
|
||||
Reference in New Issue
Block a user