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

Commit

Permalink
Add explicit children prop to useRecoilBridgeAcrossReactRoots() (#…
Browse files Browse the repository at this point in the history
…1731)

Summary:
Pull Request resolved: #1731

Add explicit `children` prop to `useRecoilBridgeAcrossReactRoots_UNSTABLE()`, similar to `<RecoilRoot>` for TypeScript.  This aligns it with the Flow typing and is necessary for the new `types/react` for React 18.

Reviewed By: mondaychen

Differential Revision: D35599296

fbshipit-source-id: 699c2c06d5a3ac6ed3f64dda824c6290a2defc42
  • Loading branch information
drarmstr authored and facebook-github-bot committed Apr 13, 2022
1 parent 1274a1c commit e9b4f45
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Update typing for family parameters to better support Map, Set, and classes with `toJSON()`. (#1709, #1703)
- Cleanup potential memory leak when using async selectors (#1714)
- Fix potentially hung async selectors when shared across multiple roots that depend on atoms initialized with promises that don't resolve (#1714)
- Add explict `children` prop to `<RecoilRoot>` and `useRecoilBridgeAcrossReactRoots_UNSTABLE()` for TypeScript for `@types/react` with React 18 (#1718, #1717, #1726, #1731)

## 0.7 (2022-03-31)

Expand Down
2 changes: 1 addition & 1 deletion typescript/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
export function useRecoilRefresher_UNSTABLE(recoilValue: RecoilValue<any>): () => void;

// useRecoilBridgeAcrossReactRoots.d.ts
export const RecoilBridge: React.FC;
export const RecoilBridge: React.FC<{children: React.ReactNode}>;
/**
* Returns a component that acts like a <RecoilRoot> but shares the same store
* as the current <RecoilRoot>.
Expand Down
7 changes: 5 additions & 2 deletions typescript/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,12 @@ const transact: (p: number) => void = useRecoilTransaction_UNSTABLE(({get, set,
*/
{
const RecoilBridgeComponent: typeof RecoilBridge = useRecoilBridgeAcrossReactRoots_UNSTABLE();
RecoilBridgeComponent({});
RecoilBridgeComponent({children: React.createElement('div')});
// eslint-disable-next-line @typescript-eslint/no-empty-function
RecoilBridgeComponent({initializeState: () => {}}); // $ExpectError
RecoilBridgeComponent({
children: React.createElement('div'),
initializeState: () => {}, // $ExpectError
});
}

/**
Expand Down

0 comments on commit e9b4f45

Please sign in to comment.