ant-design/components/config-provider/UnstableContext.tsx
二货爱吃白萝卜 45eeee60bb
feat: Add unstable api for React 19 compitable (#51979)
* chore: add unstable entrance

* chore: rest of it

* chore: use React 19

* chore: fix lint

* chore: fix lint

* chore: fix lint

* chore: fix lint

* chore: fix lint

* chore: fix lint

* chore: fix lint

* chore: test ignore 19 preload

* chore: bump rc-util

* fix: warning of pure render

* fix: warning of 19

* chore: adjust ts

* test: fix test logic

* test: fix test case

* test: fix test case

* test: fix test case

* test: fix test case

* test: fix test case

* test: fix test case

* test: fix test case

* test: fix test case

* chore: restore file

* test: fix test case

* test: fix test case

* test: fix test case

* test: fix test case

* test: fix test case

* test: update test

* test: fix test case

* test: update snapshot

* test: fix coverage

* test: fix coverage

* test: add ignore image
2024-12-18 14:09:49 +08:00

30 lines
777 B
TypeScript

import * as React from 'react';
import { render, unmount } from 'rc-util/lib/React/render';
export type UnmountType = () => Promise<void>;
export type RenderType = (
node: React.ReactElement,
container: Element | DocumentFragment,
) => UnmountType;
const defaultReactRender: RenderType = (node, container) => {
render(node, container);
return () => {
return unmount(container);
};
};
let unstableRender: RenderType = defaultReactRender;
/**
* @deprecated Set React render function for compatible usage.
* This is internal usage only compatible with React 19.
* And will be removed in next major version.
*/
export function unstableSetRender(render: RenderType) {
unstableRender = render;
}
export function getReactRender() {
return unstableRender;
}