Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Commit 91c796c

Browse files
committed
fix: extract deps to constant (#149)
1 parent 847c768 commit 91c796c

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Tippy.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export function Tippy({
5050
enabled = false;
5151
}
5252

53+
const deps = [children.type];
54+
5355
// CREATE
5456
useIsomorphicLayoutEffect(() => {
5557
const instance = tippy(component.ref, props, plugins);
@@ -73,7 +75,7 @@ export function Tippy({
7375
return () => {
7476
instance.destroy();
7577
};
76-
}, [children.type]);
78+
}, deps);
7779

7880
// UPDATE
7981
useIsomorphicLayoutEffect(() => {
@@ -102,7 +104,7 @@ export function Tippy({
102104
}
103105
});
104106

105-
useUpdateClassName(component, className, children.type);
107+
useUpdateClassName(component, className, deps);
106108

107109
return (
108110
<>

test/Tippy.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import {render, cleanup} from '@testing-library/react';
55
afterEach(cleanup);
66

77
describe('<Tippy />', () => {
8-
let instance;
8+
let instance = null;
9+
10+
afterEach(() => {
11+
instance = null;
12+
});
913

1014
function Tippy(props) {
1115
return <TippyBase {...props} onCreate={i => (instance = i)} />;
@@ -36,7 +40,7 @@ describe('<Tippy />', () => {
3640
</Tippy>,
3741
);
3842

39-
expect(instance).toBeDefined();
43+
expect(instance).not.toBeNull();
4044
});
4145

4246
test('renders react element content inside the content prop', () => {
@@ -236,7 +240,7 @@ describe('<Tippy />', () => {
236240
</Tippy>,
237241
);
238242

239-
expect(instance).toBeDefined();
243+
expect(instance).not.toBeNull();
240244
});
241245

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

0 commit comments

Comments
 (0)