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

RefForwardingComponent removed in react 18 #3370

Closed
PerfectionVR opened this issue Apr 19, 2022 · 3 comments
Closed

RefForwardingComponent removed in react 18 #3370

PerfectionVR opened this issue Apr 19, 2022 · 3 comments
Labels

Comments

@PerfectionVR
Copy link

Intended outcome:
No errors

Actual outcome:

Running the following command

tsc --project tsconfig.json --noEmit

on a typescript project would result in the following issues.

node_modules/mobx-react-lite/dist/observer.d.ts:5:84 
- error TS2694: Namespace 'React' has no exported member 'RefForwardingComponent'.

export declare function observer<P extends object, TRef = {}>(baseComponent: React.RefForwardingComponent<TRef, P>, options: IObserverOptions & {
                                                                                     ~~~~~~~~~~~~~~~~~~~~~~

node_modules/mobx-react-lite/dist/observer.d.ts:10:81 
- error TS2694: Namespace 'React' has no exported member 'RefForwardingComponent'.

export declare function observer<C extends React.FunctionComponent<any> | React.RefForwardingComponent<any>, Options extends IObserverOptions>(baseComponent: C, 
options?: Options): Options extends {
                                                                                   ~~~~~~~~~~~~~~~~~~~~~~

node_modules/mobx-react-lite/dist/observer.d.ts:12:21 
- error TS2694: Namespace 'React' has no exported member 'RefForwardingComponent'.

} ? C extends React.RefForwardingComponent<infer TRef, infer P> ? C & React.MemoExoticComponent<React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<TRef>>> : never : C & {

How to reproduce the issue:

Apolegies for the lack of codesandbox, however, this is related to other projects that are having similar issues when upgrading to react 18.

This comes down to this particular commit...
DefinitelyTyped/DefinitelyTyped#56210

RefForwardingComponent was removed with no replacement, hopefully this can be fixed one way or another.

Versions
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@types/react": "^18.0.5",
"@types/react-dom": "^18.0.1",
"mobx": "^6.5.0",
"mobx-react": "^7.3.0",

@kubk
Copy link
Collaborator

kubk commented Apr 19, 2022

Thanks for the issue. We already have a related PR to fix it: #2741

@mweststrate
Copy link
Member

Should be fixed by todays release mobx@7.4.0 / mobx-react-lite@3.4.0

@stevenKirill
Copy link

Thanks, I had the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants