-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
159 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { canUseMembrane } from './deprecateObjectProperties' | ||
import warning from './routerWarning' | ||
|
||
export default function makeStateWithLocation(state, location) { | ||
if (__DEV__ && canUseMembrane) { | ||
const stateWithLocation = { ...state } | ||
|
||
// I don't use deprecateObjectProperties here because I want to keep the | ||
// same code path between development and production, in that we just | ||
// assign extra properties to the copy of the state object in both cases. | ||
for (const prop in location) { | ||
if (!Object.prototype.hasOwnProperty.call(location, prop)) { | ||
continue | ||
} | ||
|
||
Object.defineProperty(stateWithLocation, prop, { | ||
get() { | ||
warning(false, 'Accessing location properties directly from the first argument to `getComponent`, `getComponents`, `getChildRoutes`, and `getIndexRoute` is deprecated. That argument is now the router state (`nextState` or `partialNextState`) rather than the location. To access the location, use `nextState.location` or `partialNextState.location`.') | ||
return location[prop] | ||
} | ||
}) | ||
} | ||
|
||
return stateWithLocation | ||
} | ||
|
||
return { ...state, ...location } | ||
} |
Oops, something went wrong.