File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
packages/react-on-rails-pro/src Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 1414
1515'use client' ;
1616
17- import * as React from 'react' ;
18- import { type ReactNode } from 'react' ;
17+ import { createContext , useContext , type ReactNode } from 'react' ;
1918import type { ClientGetReactServerComponentProps } from './getReactServerComponent.client.ts' ;
2019import { createRSCPayloadKey } from './utils.ts' ;
2120
@@ -25,7 +24,7 @@ type RSCContextType = {
2524 refetchComponent : ( componentName : string , componentProps : unknown ) => Promise < ReactNode > ;
2625} ;
2726
28- const RSCContext = React . createContext < RSCContextType | undefined > ( undefined ) ;
27+ const RSCContext = createContext < RSCContextType | undefined > ( undefined ) ;
2928
3029/**
3130 * Creates a provider context for React Server Components.
@@ -102,7 +101,7 @@ export const createRSCProvider = ({
102101 * ```
103102 */
104103export const useRSC = ( ) => {
105- const context = React . useContext ( RSCContext ) ;
104+ const context = useContext ( RSCContext ) ;
106105 if ( ! context ) {
107106 throw new Error ( 'useRSC must be used within a RSCProvider' ) ;
108107 }
Original file line number Diff line number Diff line change 1616
1717'use client' ;
1818
19- import * as React from 'react' ;
20- import { type ReactNode } from 'react' ;
19+ import { Component , use , type ReactNode } from 'react' ;
2120import { useRSC } from './RSCProvider.tsx' ;
2221import { ServerComponentFetchError } from './ServerComponentFetchError.ts' ;
2322
2423/**
2524 * Error boundary component for RSCRoute that adds server component name and props to the error
2625 * So, the parent ErrorBoundary can refetch the server component
2726 */
28- class RSCRouteErrorBoundary extends React . Component <
27+ class RSCRouteErrorBoundary extends Component <
2928 { children : ReactNode ; componentName : string ; componentProps : unknown } ,
3029 { error : Error | null }
3130> {
@@ -77,8 +76,8 @@ export type RSCRouteProps = {
7776} ;
7877
7978const PromiseWrapper = ( { promise } : { promise : Promise < ReactNode > } ) => {
80- // React. use is available in React 18.3+
81- const promiseResult = React . use ( promise ) ;
79+ // use is available in React 18.3+
80+ const promiseResult = use ( promise ) ;
8281
8382 // In case that an error happened during the rendering of the RSC payload before the rendering of the component itself starts
8483 // RSC bundle will return an error object serialized inside the RSC payload
You can’t perform that action at this time.
0 commit comments