Skip to content

Commit 11bcd44

Browse files
committed
add basic support for React Server Components
1 parent 54c14d6 commit 11bcd44

File tree

26 files changed

+47
-19
lines changed

26 files changed

+47
-19
lines changed

packages/react-native-web/src/exports/ActivityIndicator/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { ViewProps } from '../View';
1213

packages/react-native-web/src/exports/CheckBox/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { ColorValue } from '../../types';
1213
import type { ViewProps } from '../View';

packages/react-native-web/src/exports/FlatList/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
* @flow
99
*/
1010

11+
'use client';
12+
1113
import FlatList from '../../vendor/react-native/FlatList';
1214
export default FlatList;

packages/react-native-web/src/exports/Image/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { ImageProps } from './types';
1213

packages/react-native-web/src/exports/KeyboardAvoidingView/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { LayoutEvent, LayoutValue } from '../../types';
1213
import type { ViewProps } from '../View';

packages/react-native-web/src/exports/Modal/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { ViewProps } from '../View';
1213

packages/react-native-web/src/exports/Picker/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { PlatformMethods } from '../../types';
1213
import type { ViewProps } from '../View';

packages/react-native-web/src/exports/Pressable/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @flow strict-local
88
*/
9-
9+
'use client';
1010
'use strict';
1111

1212
import type { HoverEventsConfig } from '../../modules/useHover';

packages/react-native-web/src/exports/ScrollView/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @noflow
99
*/
10+
'use client';
1011

1112
import type { ViewProps, ViewStyle } from '../View/types';
1213

packages/react-native-web/src/exports/Switch/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*
77
* @flow
88
*/
9+
'use client';
910

1011
import type { ColorValue } from '../../types';
1112
import type { ViewProps } from '../View';

packages/react-native-web/src/exports/Text/TextAncestorContext.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*
77
* @flow strict
88
*/
9+
'use client';
910

1011
import type { Context } from 'react';
1112

packages/react-native-web/src/exports/Text/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { PlatformMethods } from '../../types';
1213
import type { TextProps } from './types';

packages/react-native-web/src/exports/TextInput/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* @flow
99
*/
10+
'use client';
1011

1112
import type { PlatformMethods } from '../../types';
1213
import type { TextInputProps } from './types';

packages/react-native-web/src/exports/TouchableHighlight/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow strict-local
88
* @format
99
*/
10-
10+
'use client';
1111
'use strict';
1212

1313
import type { ColorValue } from '../../types';

packages/react-native-web/src/exports/TouchableOpacity/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @format
99
*/
1010

11+
'use client';
1112
'use strict';
1213

1314
import type { Props as TouchableWithoutFeedbackProps } from '../TouchableWithoutFeedback';

packages/react-native-web/src/exports/TouchableWithoutFeedback/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @format
99
*/
1010

11+
'use client';
1112
'use strict';
1213

1314
import type { PressResponderConfig } from '../../modules/usePressEvents/PressResponder';

packages/react-native-web/src/exports/View/index.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @flow
99
*/
1010

11+
'use client';
12+
1113
import type { PlatformMethods } from '../../types';
1214
import type { ViewProps } from './types';
1315

@@ -69,13 +71,16 @@ const View: React.AbstractComponent<ViewProps, HTMLElement & PlatformMethods> =
6971
} = props;
7072

7173
if (process.env.NODE_ENV !== 'production') {
72-
React.Children.toArray(props.children).forEach((item) => {
73-
if (typeof item === 'string') {
74-
console.error(
75-
`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`
76-
);
77-
}
78-
});
74+
// Skip parsing RSC objects as this will prevent errors from surfacing in the renderer.
75+
if (!props.children || !('$$typeof' in props.children)) {
76+
React.Children.toArray(props.children).forEach((item) => {
77+
if (typeof item === 'string') {
78+
console.error(
79+
`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`
80+
);
81+
}
82+
});
83+
}
7984
}
8085

8186
const hasTextAncestor = React.useContext(TextAncestorContext);

packages/react-native-web/src/modules/UnimplementedView/index.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,16 @@
77
* @flow
88
*/
99

10-
import type { Node } from 'React';
11-
1210
import View from '../../exports/View';
1311
import React from 'react';
1412

1513
/**
1614
* Common implementation for a simple stubbed view.
1715
*/
18-
class UnimplementedView extends React.Component<*, *> {
19-
render(): Node {
20-
return (
21-
<View style={[unimplementedViewStyles, this.props.style]}>
22-
{this.props.children}
23-
</View>
24-
);
25-
}
16+
function UnimplementedView({ style, ...props }) {
17+
return (
18+
<View style={[unimplementedViewStyles, style]} {...props} />
19+
);
2620
}
2721

2822
const unimplementedViewStyles =

packages/react-native-web/src/modules/useLocale/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @flow strict
88
*/
99

10+
'use client';
11+
1012
import type { Node } from 'react';
1113

1214
import React, { createContext, useContext } from 'react';

packages/react-native-web/src/modules/useResponderEvents/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* @flow
88
*/
99

10+
'use client';
11+
1012
/**
1113
* Hook for integrating the Responder System into React
1214
*

packages/react-native-web/src/vendor/react-native/FlatList/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @flow
88
* @format
99
*/
10+
'use client';
1011

1112
import View, { type ViewProps } from '../../../exports/View';
1213
import StyleSheet from '../../../exports/StyleSheet';

packages/react-native-web/src/vendor/react-native/SectionList/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @format
99
*/
1010

11+
'use client';
1112
'use strict';
1213

1314
import Platform from '../../../exports/Platform';

packages/react-native-web/src/vendor/react-native/VirtualizedList/StateSafePureComponent.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @format
99
*/
1010

11+
'use client';
12+
1113
import invariant from 'fbjs/lib/invariant';
1214
import * as React from 'react';
1315

packages/react-native-web/src/vendor/react-native/VirtualizedList/VirtualizedListCellRenderer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @format
99
*/
1010

11+
'use client';
12+
1113
import type { LayoutEvent } from '../../../types';
1214
import type {
1315
FocusEvent,

packages/react-native-web/src/vendor/react-native/VirtualizedList/VirtualizedListContext.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @format
99
*/
1010

11+
'use client';
12+
1113
import typeof VirtualizedList from '../VirtualizedList';
1214

1315
import * as React from 'react';

packages/react-native-web/src/vendor/react-native/VirtualizedSectionList/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @format
99
*/
1010

11+
'use client';
12+
1113
import type {ViewToken} from '../ViewabilityHelper';
1214
import View from '../../../exports/View';
1315
import VirtualizedList from '../VirtualizedList';

0 commit comments

Comments
 (0)