Skip to content

Bug: Renders are not stable when multiple wrappers are supplied #9

@camjackson

Description

@camjackson

Given this component:

const OnMount = ({ onMount }) => {
  useEffect(() => {
    onMount();
  }, []);
  return <span>Hey</span>;
};

This test passes (the component is mounted once only):

const onMount = jest.fn()

const { rerender } = render(
  <OnMount onMount={onMount} />,
  { wrapper: wrap(withSomething()) }
)
rerender()
expect(onMount)toHaveBeenCalledTimes(1)

But if you instead do wrap(withSomething(), withASecondThing()) then the component is mounted twice and the assertion fails. Even if the wrapper components are trivial.

The bug is probably somewhere in wrap() or composeComponents() (which it calls).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions