Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add basic React Server Component support #2170

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/TransitionProgressContext.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { Animated } from 'react-native';

Expand Down
2 changes: 2 additions & 0 deletions src/components/Screen.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React from 'react';
import { Animated, View, Platform } from 'react-native';

Expand Down
3 changes: 3 additions & 0 deletions src/components/Screen.web.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { ScreenProps } from 'react-native-screens';
import { Animated, View } from 'react-native';
import React from 'react';
Expand All @@ -8,6 +10,7 @@ export const InnerScreen = View;

// We're using class component here because of the error from reanimated:
// createAnimatedComponent` does not support stateless functional components; use a class component instead.
// NOTE: React Server Components do not support class components.
export class NativeScreen extends React.Component<ScreenProps> {
render(): JSX.Element {
let {
Expand Down
2 changes: 2 additions & 0 deletions src/components/ScreenContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Platform, View } from 'react-native';
import React from 'react';
import { ScreenContainerProps } from 'react-native-screens';
Expand All @@ -8,10 +10,10 @@
import ScreenNavigationContainerNativeComponent from '../fabric/ScreenNavigationContainerNativeComponent';

export const NativeScreenContainer: React.ComponentType<ScreenContainerProps> =
Platform.OS !== 'web' ? (ScreenContainerNativeComponent as any) : View;

Check warning on line 13 in src/components/ScreenContainer.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type
export const NativeScreenNavigationContainer: React.ComponentType<ScreenContainerProps> =
Platform.OS !== 'web'
? (ScreenNavigationContainerNativeComponent as any)

Check warning on line 16 in src/components/ScreenContainer.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type
: View;

function ScreenContainer(props: ScreenContainerProps) {
Expand Down
2 changes: 2 additions & 0 deletions src/components/ScreenStack.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React from 'react';
import { ScreenStackProps, freezeEnabled } from 'react-native-screens';
import DelayedFreeze from './helpers/DelayedFreeze';
Expand All @@ -5,7 +7,7 @@
// Native components
import ScreenStackNativeComponent from '../fabric/ScreenStackNativeComponent';
const NativeScreenStack: React.ComponentType<ScreenStackProps> =
ScreenStackNativeComponent as any;

Check warning on line 10 in src/components/ScreenStack.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type

function ScreenStack(props: ScreenStackProps) {
const { children, gestureDetectorBridge, ...rest } = props;
Expand Down
2 changes: 2 additions & 0 deletions src/components/ScreenStackHeaderConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React from 'react';
import {
HeaderSubviewTypes,
Expand All @@ -11,10 +13,10 @@
import ScreenStackHeaderSubviewNativeComponent from '../fabric/ScreenStackHeaderSubviewNativeComponent';

export const ScreenStackHeaderConfig: React.ComponentType<ScreenStackHeaderConfigProps> =
ScreenStackHeaderConfigNativeComponent as any;

Check warning on line 16 in src/components/ScreenStackHeaderConfig.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type
export const ScreenStackHeaderSubview: React.ComponentType<
React.PropsWithChildren<ViewProps & { type?: HeaderSubviewTypes }>
> = ScreenStackHeaderSubviewNativeComponent as any;

Check warning on line 19 in src/components/ScreenStackHeaderConfig.tsx

View workflow job for this annotation

GitHub Actions / install-and-lint

Unexpected any. Specify a different type

export const ScreenStackHeaderBackButtonImage = (
props: ImageProps
Expand Down
2 changes: 2 additions & 0 deletions src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React from 'react';
import {
isSearchBarAvailableForCurrentPlatform,
Expand Down
2 changes: 2 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Platform, UIManager } from 'react-native';

// const that tells if the library should use new implementation, will be undefined for older versions
Expand Down
2 changes: 2 additions & 0 deletions src/fabric/FullWindowOverlayNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps } from 'react-native';

Expand Down
2 changes: 2 additions & 0 deletions src/fabric/ModalScreenNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps, ColorValue } from 'react-native';
import type {
Expand Down
2 changes: 2 additions & 0 deletions src/fabric/NativeScreensModule.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

/* eslint-disable @typescript-eslint/ban-types */
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
Expand Down
2 changes: 2 additions & 0 deletions src/fabric/ScreenContainerNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps } from 'react-native';

Expand Down
2 changes: 2 additions & 0 deletions src/fabric/ScreenNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps, ColorValue } from 'react-native';
import type {
Expand Down
2 changes: 2 additions & 0 deletions src/fabric/ScreenNavigationContainerNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps } from 'react-native';

Expand Down
2 changes: 2 additions & 0 deletions src/fabric/ScreenStackHeaderConfigNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps, ColorValue } from 'react-native';
import type {
Expand Down
2 changes: 2 additions & 0 deletions src/fabric/ScreenStackHeaderSubviewNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps } from 'react-native';
import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
Expand Down
2 changes: 2 additions & 0 deletions src/fabric/ScreenStackNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps } from 'react-native';
import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes';
Expand Down
2 changes: 2 additions & 0 deletions src/fabric/SearchBarNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

/* eslint-disable */
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { ViewProps, ColorValue, HostComponent } from 'react-native';
Expand Down
2 changes: 2 additions & 0 deletions src/native-stack/contexts/GHContext.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import React, { PropsWithChildren } from 'react';
import { GestureProviderProps } from '../types';

Expand Down
Loading