Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Update RecoilRootProps type for React 18 types #1718

Closed
wants to merge 2 commits into from

Conversation

dqn
Copy link
Contributor

@dqn dqn commented Apr 8, 2022

Fixes #1717

Since @types/react v18, Implicit children was removed from React.FC. This change works for @types/react v18 and earlier.
DefinitelyTyped/DefinitelyTyped#56210

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 8, 2022
@facebook-github-bot
Copy link
Contributor

@mondaychen has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

children?: React.ReactNode | undefined,
} | {
override: false,
children?: React.ReactNode | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
children?: React.ReactNode | undefined,
children: React.ReactNode,

@@ -29,7 +29,11 @@
export type RecoilRootProps = {
initializeState?: (mutableSnapshot: MutableSnapshot) => void,
override?: true,
} | {override: false};
children?: React.ReactNode | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this opportunity to make it required and align with the Flow type https://github.com/facebookexperimental/Recoil/blob/main/packages/recoil/core/Recoil_RecoilRoot.js#L66

Suggested change
children?: React.ReactNode | undefined,
children: React.ReactNode,

(also I think undefined is included in React.ReactNode)

@dqn dqn force-pushed the react-18-types branch from 57573be to 9cf05ec Compare April 9, 2022 15:02
@facebook-github-bot
Copy link
Contributor

@dqn has updated the pull request. You must reimport the pull request before landing.

@dqn
Copy link
Contributor Author

dqn commented Apr 9, 2022

@mondaychen Thank you for reviewing! I fixed that.

@dqn dqn requested a review from mondaychen April 9, 2022 15:05
@facebook-github-bot
Copy link
Contributor

@mondaychen has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mondaychen
Copy link
Contributor

@facebook-github-bot
Copy link
Contributor

@dqn has updated the pull request. You must reimport the pull request before landing.

@dqn
Copy link
Contributor Author

dqn commented Apr 10, 2022

Fixed.

@facebook-github-bot
Copy link
Contributor

@mondaychen has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@@ -34,6 +34,7 @@
useRecoilState_TRANSITION_SUPPORT_UNSTABLE,
useRecoilValueLoadable_TRANSITION_SUPPORT_UNSTABLE,
} from 'recoil';
import React = require('react');
Copy link
Contributor

@mondaychen mondaychen Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange. Should this be import * as React from 'react'? Or const React = require('react')? Now it looks like a mix of the two

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use default import by adding the compilerOptions esModuleInterop: true, but I use namespace import because I found it used in other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: import = require() is a valid syntax for importing modules exported with export = .
https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require

@dqn dqn force-pushed the react-18-types branch from 2db5a0f to f039b4d Compare April 11, 2022 15:03
@facebook-github-bot
Copy link
Contributor

@dqn has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@mondaychen has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

AlexGuz23 pushed a commit to AlexGuz23/Recoil that referenced this pull request Nov 3, 2022
Summary:
Fixes facebookexperimental/Recoil#1717

Since types/react v18, Implicit `children` was removed from `React.FC`. This change works for types/react v18 and earlier.
DefinitelyTyped/DefinitelyTyped#56210

Pull Request resolved: facebookexperimental/Recoil#1718

Reviewed By: drarmstr

Differential Revision: D35501855

Pulled By: mondaychen

fbshipit-source-id: cf469b96a5220966718270e43e3f0503e144acf3
snipershooter0701 pushed a commit to snipershooter0701/Recoil that referenced this pull request Mar 5, 2023
Summary:
Fixes facebookexperimental/Recoil#1717

Since types/react v18, Implicit `children` was removed from `React.FC`. This change works for types/react v18 and earlier.
DefinitelyTyped/DefinitelyTyped#56210

Pull Request resolved: facebookexperimental/Recoil#1718

Reviewed By: drarmstr

Differential Revision: D35501855

Pulled By: mondaychen

fbshipit-source-id: cf469b96a5220966718270e43e3f0503e144acf3
eagle2722 added a commit to eagle2722/Recoil that referenced this pull request Sep 21, 2024
Summary:
Fixes facebookexperimental/Recoil#1717

Since types/react v18, Implicit `children` was removed from `React.FC`. This change works for types/react v18 and earlier.
DefinitelyTyped/DefinitelyTyped#56210

Pull Request resolved: facebookexperimental/Recoil#1718

Reviewed By: drarmstr

Differential Revision: D35501855

Pulled By: mondaychen

fbshipit-source-id: cf469b96a5220966718270e43e3f0503e144acf3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. TypeScript / Flow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RecoilRoot doesn't have children attribute
4 participants