Skip to content

Question: injectEnvironment can only be called once - Jest #559

@JamieDixon

Description

@JamieDixon

I believe this issue will be fixed when React 15.4 is released as per facebook/react#7386 (comment)

I just want to check this is indeed the case and that there's no another issue causing this error that could be fixed in create-react-app.

How to reproduce:

  1. npm install velocity-react
  2. Create a component that utilized velocity-react:
<div>
     <VelocityTransitionGroup
         enter={{ animation: { opacity: 1 }, duration: 200 }}
         leave={{ animation: { opacity: 0 }, duration: 200 }}
         runOnMount
       >
          <div />
       </VelocityTransitionGroup>
</div>
  1. Write a Jest snapshot test that checks that this component renders correctly:
it('renders correctly', () => {
    const tree = renderer.create(
        <Component />
    ).toJSON();

    expect(tree).toMatchSnapshot();
});
  1. Observe the error in the console

Invariant Violation: ReactCompositeComponent: injectEnvironment() can only be called once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions