Compare commits

..

4 Commits

Author SHA1 Message Date
Brent Vatne
ed9ee4d5e5 Release 2.18.3 2018-11-26 14:01:30 -08:00
Sibelius Seraphini
36f9788e85 feat(ref): use react-is to enable forwardRef on 2.x, fix #5193 (#5223)
* feat(ref): use react-is to enable forwardRef on 2.x, fix #5193

* docs(changelog): add changes to changelog
2018-11-27 03:11:53 +07:00
Brent Vatne
712ec9bab1 Release 2.18.2 2018-10-26 07:38:11 -07:00
Brent Vatne
786456b645 Revert "Backport child navigation cache fix"
This reverts commit 445e4d95b8.
2018-10-26 07:36:53 -07:00
9 changed files with 41 additions and 33 deletions

View File

@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
## [2.18.3] - [2018-11-26](https://github.com/react-navigation/react-navigation/releases/tag/2.18.3)
### Fixed
- Support React.forwardRef on createStackNavigator
## [2.18.2] - [2018-10-26](https://github.com/react-navigation/react-navigation/releases/tag/2.18.2)
### Fixed
- Revert "Backport fix for child navigation object caching" due to edge case with transitioner
## [2.18.1] - [2018-10-23](https://github.com/react-navigation/react-navigation/releases/tag/2.18.1)
### Fixed
@@ -239,7 +252,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
- Improved examples
[Unreleased]: https://github.com/react-navigation/react-navigation/compare/2.18.1...HEAD
[Unreleased]: https://github.com/react-navigation/react-navigation/compare/2.18.3...HEAD
[2.18.3]: https://github.com/react-navigation/react-navigation/compare/2.18.2...2.18.3
[2.18.2]: https://github.com/react-navigation/react-navigation/compare/2.18.1...2.18.2
[2.18.1]: https://github.com/react-navigation/react-navigation/compare/2.18.0...2.18.1
[2.18.0]: https://github.com/react-navigation/react-navigation/compare/2.17.0...2.18.0
[2.17.0]: https://github.com/react-navigation/react-navigation/compare/2.16.0...2.17.0

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation",
"version": "2.18.1",
"version": "2.18.3",
"description": "Routing and navigation for your React Native apps",
"main": "src/react-navigation.js",
"repository": {
@@ -35,6 +35,7 @@
"hoist-non-react-statics": "^2.2.0",
"path-to-regexp": "^1.7.0",
"query-string": "^6.1.0",
"react-is": "^16.5.2",
"react-lifecycles-compat": "^3",
"react-native-safe-area-view": "0.11.0",
"react-native-screens": "^1.0.0-alpha.11",
@@ -62,7 +63,7 @@
"lint-staged": "^4.2.1",
"prettier": "^1.12.1",
"prettier-eslint": "^8.8.1",
"react": "16.2.0",
"react": "16.5.2",
"react-native": "^0.52.0",
"react-native-vector-icons": "^4.2.0",
"react-test-renderer": "^16.0.0"

View File

@@ -1,7 +1,6 @@
import getChildEventSubscriber from './getChildEventSubscriber';
import getChildRouter from './getChildRouter';
import getNavigationActionCreators from './routers/getNavigationActionCreators';
import getChildrenNavigationCache from './getChildrenNavigationCache';
import invariant from './utils/invariant';
const createParamGetter = route => (paramName, defaultValue) => {
@@ -15,7 +14,8 @@ const createParamGetter = route => (paramName, defaultValue) => {
};
function getChildNavigation(navigation, childKey, getCurrentParentNavigation) {
const children = getChildrenNavigationCache(navigation);
const children =
navigation._childrenNavigation || (navigation._childrenNavigation = {});
const childRoute = navigation.state.routes.find(r => r.key === childKey);

View File

@@ -1,16 +0,0 @@
export default function getChildrenNavigationCache(navigation) {
if (!navigation) {
return {};
}
let childrenNavigationCache =
navigation._childrenNavigation || (navigation._childrenNavigation = {});
let childKeys = navigation.state.routes.map(route => route.key);
Object.keys(childrenNavigationCache).forEach(cacheKey => {
if (!childKeys.includes(cacheKey)) {
delete childrenNavigationCache[cacheKey];
}
});
return navigation._childrenNavigation;
}

View File

@@ -1,6 +1,5 @@
import getNavigationActionCreators from './routers/getNavigationActionCreators';
import getChildNavigation from './getChildNavigation';
import getChildrenNavigationCache from './getChildrenNavigationCache';
export default function getNavigation(
router,
@@ -39,7 +38,6 @@ export default function getNavigation(
};
},
dangerouslyGetParent: () => null,
_childrenNavigation: getChildrenNavigationCache(getCurrentNavigation()),
};
const actionCreators = {

View File

@@ -12,6 +12,10 @@ ProfileNavigator.router = StackRouter({
},
});
const ScreenWithForwardRef = React.forwardRef((props, ref) => (
<div ref={ref} />
));
describe('validateRouteConfigMap', () => {
test('Fails on empty bare screen', () => {
const invalidMap = {
@@ -57,4 +61,10 @@ describe('validateRouteConfigMap', () => {
};
validateRouteConfigMap(validMap);
});
test('Succeeds on React.forwardRef', () => {
const validMap = {
Chat: ScreenWithForwardRef,
};
validateRouteConfigMap(validMap);
});
});

View File

@@ -1,3 +1,4 @@
import { isValidElementType } from 'react-is';
import invariant from '../utils/invariant';
/**
@@ -23,7 +24,7 @@ export default function getScreenForRouteName(routeConfigs, routeName) {
if (typeof routeConfig.getScreen === 'function') {
const screen = routeConfig.getScreen();
invariant(
typeof screen === 'function',
isValidElementType(screen),
`The getScreen defined for route '${routeName} didn't return a valid ` +
'screen or navigator.\n\n' +
'Please pass it like this:\n' +

View File

@@ -1,3 +1,4 @@
import { isValidElementType } from 'react-is';
import invariant from '../utils/invariant';
/**
@@ -17,9 +18,7 @@ function validateRouteConfigMap(routeConfigs) {
if (
!screenComponent ||
(typeof screenComponent !== 'function' &&
typeof screenComponent !== 'string' &&
!routeConfig.getScreen)
(!isValidElementType(screenComponent) && !routeConfig.getScreen)
) {
throw new Error(`The component for route '${routeName}' must be a React component. For example:

View File

@@ -5601,15 +5601,15 @@ react-transform-hmr@^1.0.4:
global "^4.3.0"
react-proxy "^1.1.7"
react@16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
integrity sha512-ZmIomM7EE1DvPEnSFAHZn9Vs9zJl5A9H7el0EGTE6ZbW9FKe/14IYAlPbC8iH25YarEQxZL+E8VW7Mi7kfQrDQ==
react@16.5.2:
version "16.5.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.5.2.tgz#19f6b444ed139baa45609eee6dc3d318b3895d42"
integrity sha512-FDCSVd3DjVTmbEAjUNX6FgfAmQ+ypJfHUsqUJOYNCBUp1h8lqmtC+0mXJ+JjsWx4KAVTkk1vKd1hLQPvEviSuw==
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"
prop-types "^15.6.2"
schedule "^0.5.0"
read-pkg-up@^1.0.1:
version "1.0.1"