@react-navigation/native 3.6.0-alpha.5 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,7 @@ function validateProps(props) {
23
23
  screenProps,
24
24
  persistNavigationState,
25
25
  loadNavigationState,
26
+ theme,
26
27
  ...containerProps
27
28
  } = props;
28
29
  /* eslint-enable no-unused-vars */
@@ -65,6 +66,10 @@ export default function createNavigationContainer(Component) {
65
66
  static router = Component.router;
66
67
  static navigationOptions = null;
67
68
 
69
+ static defaultProps = {
70
+ theme: 'light'
71
+ };
72
+
68
73
  static getDerivedStateFromProps(nextProps) {
69
74
  validateProps(nextProps);
70
75
  return null;
@@ -105,21 +110,6 @@ export default function createNavigationContainer(Component) {
105
110
  return isStateful(this.props);
106
111
  }
107
112
 
108
- _validateProps(props) {
109
- if (this._isStateful()) {
110
- return;
111
- }
112
-
113
- // eslint-disable-next-line no-unused-vars
114
- const { navigation, screenProps, ...containerProps } = props;
115
-
116
- const keys = Object.keys(containerProps);
117
-
118
- if (keys.length !== 0) {
119
- throw new Error('This navigator has both navigation and container props, so it is ' + `unclear if it should own its own state. Remove props: "${keys.join(', ')}" ` + 'if the navigator should get its state from the navigation prop. If the ' + 'navigator should maintain its own state, do not pass a navigation prop.');
120
- }
121
- }
122
-
123
113
  _handleOpenURL = ({ url }) => {
124
114
  const { enableURLHandling, uriPrefix } = this.props;
125
115
  if (enableURLHandling === false) {
@@ -334,6 +324,8 @@ export default function createNavigationContainer(Component) {
334
324
  _getTheme = () => {
335
325
  if (this.props.theme === 'light' || this.props.theme === 'dark') {
336
326
  return this.props.theme;
327
+ } else if (this.props.theme === 'no-preference') {
328
+ return 'light';
337
329
  } else {
338
330
  console.warn(`Invalid theme provided: ${this.props.theme}. Only 'light' and 'dark' are supported. Falling back to 'light'`);
339
331
  return 'light';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-navigation/native",
3
- "version": "3.6.0-alpha.5",
3
+ "version": "3.6.2",
4
4
  "description": "React Native support for React Navigation",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -34,6 +34,7 @@ function validateProps(props) {
34
34
  screenProps,
35
35
  persistNavigationState,
36
36
  loadNavigationState,
37
+ theme,
37
38
  ...containerProps
38
39
  } = props;
39
40
  /* eslint-enable no-unused-vars */
@@ -89,6 +90,10 @@ export default function createNavigationContainer(Component) {
89
90
  static router = Component.router;
90
91
  static navigationOptions = null;
91
92
 
93
+ static defaultProps = {
94
+ theme: 'light',
95
+ };
96
+
92
97
  static getDerivedStateFromProps(nextProps) {
93
98
  validateProps(nextProps);
94
99
  return null;
@@ -138,28 +143,6 @@ export default function createNavigationContainer(Component) {
138
143
  return isStateful(this.props);
139
144
  }
140
145
 
141
- _validateProps(props) {
142
- if (this._isStateful()) {
143
- return;
144
- }
145
-
146
- // eslint-disable-next-line no-unused-vars
147
- const { navigation, screenProps, ...containerProps } = props;
148
-
149
- const keys = Object.keys(containerProps);
150
-
151
- if (keys.length !== 0) {
152
- throw new Error(
153
- 'This navigator has both navigation and container props, so it is ' +
154
- `unclear if it should own its own state. Remove props: "${keys.join(
155
- ', '
156
- )}" ` +
157
- 'if the navigator should get its state from the navigation prop. If the ' +
158
- 'navigator should maintain its own state, do not pass a navigation prop.'
159
- );
160
- }
161
- }
162
-
163
146
  _handleOpenURL = ({ url }) => {
164
147
  const { enableURLHandling, uriPrefix } = this.props;
165
148
  if (enableURLHandling === false) {
@@ -408,6 +391,8 @@ export default function createNavigationContainer(Component) {
408
391
  _getTheme = () => {
409
392
  if (this.props.theme === 'light' || this.props.theme === 'dark') {
410
393
  return this.props.theme;
394
+ } else if (this.props.theme === 'no-preference') {
395
+ return 'light';
411
396
  } else {
412
397
  console.warn(
413
398
  `Invalid theme provided: ${