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 imagepull/52051/head
parent
ee2e13786f
commit
45eeee60bb
@ -1 +1 @@
|
||||
lint-staged
|
||||
lint-staged
|
@ -0,0 +1,44 @@
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { Modal, unstableSetRender } from 'antd';
|
||||
|
||||
import { waitFakeTimer19 } from '../../tests/utils';
|
||||
|
||||
// TODO: Remove this. Mock for React 19
|
||||
jest.mock('react-dom', () => {
|
||||
const realReactDOM = jest.requireActual('react-dom');
|
||||
|
||||
if (realReactDOM.version.startsWith('19')) {
|
||||
const realReactDOMClient = jest.requireActual('react-dom/client');
|
||||
realReactDOM.createRoot = realReactDOMClient.createRoot;
|
||||
}
|
||||
|
||||
return realReactDOM;
|
||||
});
|
||||
|
||||
describe('unstable', () => {
|
||||
beforeEach(() => {
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('unstableSetRender', async () => {
|
||||
if (ReactDOM.version.startsWith('19')) {
|
||||
unstableSetRender((node, container) => {
|
||||
const root = (ReactDOM as any).createRoot(container);
|
||||
root.render(node);
|
||||
return async () => {
|
||||
root.unmount();
|
||||
};
|
||||
});
|
||||
|
||||
Modal.info({ content: 'unstableSetRender' });
|
||||
|
||||
await waitFakeTimer19();
|
||||
|
||||
expect(document.querySelector('.ant-modal')).toBeTruthy();
|
||||
}
|
||||
});
|
||||
});
|
@ -1,3 +1,5 @@
|
||||
import { extendTest } from '../../../tests/shared/demoTest';
|
||||
|
||||
extendTest('auto-complete');
|
||||
extendTest('auto-complete', {
|
||||
skip: ['row-selection-debug.tsx'],
|
||||
});
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { imageDemoTest } from '../../../tests/shared/imageTest';
|
||||
|
||||
describe('AutoComplete image', () => {
|
||||
imageDemoTest('auto-complete');
|
||||
imageDemoTest('auto-complete', {
|
||||
skip: ['row-selection-debug.tsx'],
|
||||
});
|
||||
});
|
||||
|
@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import { extendTest } from '../../../tests/shared/demoTest';
|
||||
|
||||
extendTest('mentions');
|
||||
extendTest('mentions', {
|
||||
skip: ['autoSize.tsx'],
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { imageDemoTest } from '../../../tests/shared/imageTest';
|
||||
|
||||
describe('Table image', () => {
|
||||
imageDemoTest('table', { skip: ['virtual-list.tsx'] });
|
||||
imageDemoTest('table', { skip: ['virtual-list.tsx', 'row-selection-debug.tsx'] });
|
||||
});
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { extendTest } from '../../../tests/shared/demoTest';
|
||||
|
||||
extendTest('tabs');
|
||||
extendTest('tabs', {
|
||||
skip: ['custom-tab-bar-node.tsx'],
|
||||
});
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue