Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Tippy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export function Tippy({
enabled = false;
}

const deps = [children.type];

// CREATE
useIsomorphicLayoutEffect(() => {
const instance = tippy(component.ref, props, plugins);
Expand All @@ -73,7 +75,7 @@ export function Tippy({
return () => {
instance.destroy();
};
}, [children.type]);
}, deps);

// UPDATE
useIsomorphicLayoutEffect(() => {
Expand Down Expand Up @@ -102,7 +104,7 @@ export function Tippy({
}
});

useUpdateClassName(component, className, children.type);
useUpdateClassName(component, className, deps);

return (
<>
Expand Down
10 changes: 7 additions & 3 deletions test/Tippy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {render, cleanup} from '@testing-library/react';
afterEach(cleanup);

describe('<Tippy />', () => {
let instance;
let instance = null;

afterEach(() => {
instance = null;
});

function Tippy(props) {
return <TippyBase {...props} onCreate={i => (instance = i)} />;
Expand Down Expand Up @@ -36,7 +40,7 @@ describe('<Tippy />', () => {
</Tippy>,
);

expect(instance).toBeDefined();
expect(instance).not.toBeNull();
});

test('renders react element content inside the content prop', () => {
Expand Down Expand Up @@ -236,7 +240,7 @@ describe('<Tippy />', () => {
</Tippy>,
);

expect(instance).toBeDefined();
expect(instance).not.toBeNull();
});

test('refs are preserved on the child', done => {
Expand Down