Skip to content

Commit

Permalink
Add basic support for React Server Components
Browse files Browse the repository at this point in the history
Close #2678
Fix #2672

Co-authored-by: evanbacon <[email protected]>
  • Loading branch information
EvanBacon authored and necolas committed Oct 16, 2024
1 parent bb7911c commit 1d4568d
Show file tree
Hide file tree
Showing 33 changed files with 64 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*
* @flow
*/

'use client';

import canUseDOM from '../../modules/canUseDom';

function isScreenReaderEnabled(): Promise<*> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

import * as React from 'react';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Animated/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
* @flow
*/

'use client';

import Animated from '../../vendor/react-native/Animated/Animated';
export default Animated;
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/AppRegistry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

import type { Application } from './renderApplication';
import type { ComponentType, Node } from 'react';

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/AppState/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @noflow
*/

'use client';

import invariant from 'fbjs/lib/invariant';
import EventEmitter from '../../vendor/react-native/vendor/emitter/EventEmitter';
import canUseDOM from '../../modules/canUseDom';
Expand Down
3 changes: 3 additions & 0 deletions packages/react-native-web/src/exports/Appearance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*
* @flow
*/

'use client';

import canUseDOM from '../../modules/canUseDom';

export type ColorSchemeName = 'light' | 'dark';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/CheckBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Clipboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

let clipboardAvailable;

export default class Clipboard {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Dimensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

import type { EventSubscription } from '../../vendor/react-native/vendor/emitter/EventEmitter';
import invariant from 'fbjs/lib/invariant';
import canUseDOM from '../../modules/canUseDom';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/FlatList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
* @flow
*/

'use client';

import FlatList from '../../vendor/react-native/FlatList';
export default FlatList;
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

import * as React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

import * as React from 'react';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-web/src/exports/Pressable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow strict-local
*/

'use strict';
'use client';

import type { HoverEventsConfig } from '../../modules/useHover';
import type { PressResponderConfig } from '../../modules/usePressEvents/PressResponder';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/ProgressBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @flow
*/

'use client';

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

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/ScrollView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @noflow
*/

'use client';

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

import Dimensions from '../Dimensions';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/SectionList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
* @flow
*/

'use client';

import SectionList from '../../vendor/react-native/SectionList';
export default SectionList;
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Switch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @flow
*/

'use client';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @flow strict
*/

'use client';

import type { Context } from 'react';

import { createContext } from 'react';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/Text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/TextInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

'use strict';
'use client';

import type { ColorValue } from '../../types';
import type { Props as TouchableWithoutFeedbackProps } from '../TouchableWithoutFeedback';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

'use strict';
'use client';

import type { Props as TouchableWithoutFeedbackProps } from '../TouchableWithoutFeedback';
import type { ViewProps } from '../View';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @format
*/

'use strict';
'use client';

import type { PressResponderConfig } from '../../modules/usePressEvents/PressResponder';
import type { ViewProps } from '../View';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/View/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
* @flow
*/

'use client';

import VirtualizedList from '../../vendor/react-native/VirtualizedList';
export default VirtualizedList;
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/createElement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @noflow
*/

'use client';

import AccessibilityUtil from '../../modules/AccessibilityUtil';
import createDOMProps from '../../modules/createDOMProps';
import React from 'react';
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @noflow
*/

'use client';

import {
hydrate as domLegacyHydrate,
render as domLegacyRender
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-web/src/exports/useColorScheme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @flow
*/

'use client';

import * as React from 'react';
import type { ColorSchemeName } from '../Appearance';
import Appearance from '../Appearance';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
* @flow strict
*/

'use client';

import { useLocaleContext } from '../../modules/useLocale';
export default useLocaleContext;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @flow strict-local
*/

'use strict';
'use client';

import type { DisplayMetrics } from '../Dimensions';

Expand Down
12 changes: 3 additions & 9 deletions packages/react-native-web/src/modules/UnimplementedView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@
*
* @flow
*/

import type { Node } from 'React';
import type { ViewProps } from '../../exports/View/types';

import View from '../../exports/View';
import React from 'react';

/**
* Common implementation for a simple stubbed view.
*/
class UnimplementedView extends React.Component<*, *> {
render(): Node {
return (
<View style={[unimplementedViewStyles, this.props.style]}>
{this.props.children}
</View>
);
}
function UnimplementedView({ style, ...props }: ViewProps): Node {
return <View {...props} style={[unimplementedViewStyles, style]} />;
}

const unimplementedViewStyles =
Expand Down

0 comments on commit 1d4568d

Please sign in to comment.