Skip to content

Support getSnapshotBeforeUpdate for shallow #1602

@koba04

Description

@koba04

Current behavior

React v16.3.0 introduced new lifecycle method called getSnapshotBeforeUpdate.
the method isn't supported by ShallowRenderer so we have to add support the method on enzyme if needed.
The method is called at the same timing with componentWillUpdate so we might need some hacks ShallowRenderer internals.
In addition to that, the arguments of componentDidUpdate have been changed, which accepts snapshot as the 3rd argument.

https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html

Should enzyme support this method?
If so, I'd like to work on based on #1192

Expected behavior

Your environment

API

  • shallow
  • mount
  • render

Version

library version
Enzyme 3.3.0
React 16.3.0

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions