mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(react): callback refs now work correctly with ionic components (#23152)
resolves #23153
This commit is contained in:

committed by
GitHub

parent
004885bfd4
commit
0dd189e2c0
@ -27,7 +27,7 @@ describe('createComponent - events', () => {
|
||||
});
|
||||
|
||||
describe('createComponent - ref', () => {
|
||||
test('should pass ref on to web component instance', () => {
|
||||
test('should pass ref on to web component instance (RefObject)', () => {
|
||||
const ionButtonRef: React.RefObject<any> = React.createRef();
|
||||
const IonButton = createReactComponent<JSX.IonButton, HTMLIonButtonElement>('ion-button');
|
||||
|
||||
@ -35,6 +35,16 @@ describe('createComponent - ref', () => {
|
||||
const ionButtonItem = getByText('ButtonNameA');
|
||||
expect(ionButtonRef.current).toEqual(ionButtonItem);
|
||||
});
|
||||
|
||||
test('should pass ref on to web component instance (RefCallback)', () => {
|
||||
let current
|
||||
const ionButtonRef: React.RefCallback<any> = value => current = value;
|
||||
const IonButton = createReactComponent<JSX.IonButton, HTMLIonButtonElement>('ion-button');
|
||||
|
||||
const { getByText } = render(<IonButton ref={ionButtonRef}>ButtonNameA</IonButton>);
|
||||
const ionButtonItem = getByText('ButtonNameA');
|
||||
expect(current).toEqual(ionButtonItem);
|
||||
});
|
||||
});
|
||||
|
||||
describe('createComponent - strict mode', () => {
|
||||
|
Reference in New Issue
Block a user