diff --git a/src/Tippy.js b/src/Tippy.js index 335c79e..bd9da22 100644 --- a/src/Tippy.js +++ b/src/Tippy.js @@ -50,6 +50,8 @@ export function Tippy({ enabled = false; } + const deps = [children.type]; + // CREATE useIsomorphicLayoutEffect(() => { const instance = tippy(component.ref, props, plugins); @@ -73,7 +75,7 @@ export function Tippy({ return () => { instance.destroy(); }; - }, [children.type]); + }, deps); // UPDATE useIsomorphicLayoutEffect(() => { @@ -102,7 +104,7 @@ export function Tippy({ } }); - useUpdateClassName(component, className, children.type); + useUpdateClassName(component, className, deps); return ( <> diff --git a/test/Tippy.test.js b/test/Tippy.test.js index da22460..772d099 100644 --- a/test/Tippy.test.js +++ b/test/Tippy.test.js @@ -5,7 +5,11 @@ import {render, cleanup} from '@testing-library/react'; afterEach(cleanup); describe('', () => { - let instance; + let instance = null; + + afterEach(() => { + instance = null; + }); function Tippy(props) { return (instance = i)} />; @@ -36,7 +40,7 @@ describe('', () => { , ); - expect(instance).toBeDefined(); + expect(instance).not.toBeNull(); }); test('renders react element content inside the content prop', () => { @@ -236,7 +240,7 @@ describe('', () => { , ); - expect(instance).toBeDefined(); + expect(instance).not.toBeNull(); }); test('refs are preserved on the child', done => {