enzymejs / enzymejs/enzyme

React hooks support checklist

Open
#2,011 55 comments 556 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
19.8k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Sorry for removing issue template. Since the React 16.8 is out we can start to work on hooks support in enzyme now. Previously I tried to open PR in #2008 to help with this but found out that there are [too many apis in React hooks](https://reactjs.org/docs/hooks-reference.html). After some thinking I feel it's better to track all of the supports / PR in one issues, and create one PR for each hooks api (`useState`, `useEffect`, etc).

- [x] useState (#1938, #1996, Test case PR #2008 #2029 #2041)
- [x] useEffect (Test case PR #2034 #2041 ; Currently not work in shallow renderer, see facebook/react#15275)
- [x] useContext (Test case PR #2041)
- [x] useReducer (Test case PR #2041)
- [x] useCallback (Test case PR #2148)
- [x] useMemo (Test case PR #2144)
- [x] useRef (#1938, Test case PR #2162)
- [x] useImperativeHandle (#2039, Test case PR #2162)
- [x] useLayoutEffect (Test case PR #2121)
- [x] useDebugValue(Test case PR #2162)
- [x] custom hooks (#1996)

known issues (some are resolved with newer version of react):

- [x] `setState` returned from `useState` not works with `shallow` before react@16.8.5 . Fixed in https://github.com/facebook/react/pull/15120 .
- [ ] `useEffect` and `useLayoutEffect` not works with `shallow` because react shallow renderer doesn't run it. (facebook/react#15275)
- [ ] `useCallback` doesn't memoize callback in react shallow renderer (https://github.com/facebook/react/issues/15774)

Currently I'm working in `useState` (#2008) and I'm glad to see if anyone else would like to help to support other apis. For now we need to add many tests to make sure what is working in enzyme, and what is not, then add patch / feature into it. I can help to maintain the above checklist if there are any related issues / PR .

I'm simply volunteer to do this and not a main maintainer here though so @ljharb if you have had any plan / schedule on this feel free to tell me and I can change or close this :-)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.