Skip to content

Change props on same component instance, reprise #273

Closed
@eschiebel

Description

@eschiebel
  • react-testing-library version:5.4.4
  • react version:16.7.0
  • node version: v8.10.0
  • npm (or yarn) version: yarn 10.1.1

Relevant code or config:

in a previously closed ticket #65 (comment) you suggest calling

render(<C {...newProps}/>, container)

to rerender with new props, but when I do this, the existing instance is not updated, but I get a new instance of the component.

What you did:

  1. set a breakpoint in my component's constructor, render, and componentDidUpdate functions
  2. call {{const {container} = render()}}
  3. The constructor and render breakpoints are hit. In render, I set window.xxx=this
  4. call render(<C value="177"/>, container)
  5. I see the constructor and render called. componentDidUpdate is not called and window.xxx!==this

What happened:

Reproduction:

https://codesandbox.io/s/jj56q52rqw

You can see that the test output renders 2 instances of the Hello component, and that componentDidUpdate is never called

Problem description:

I don't know how to test property change behavior on my components

Suggested solution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions