Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with React 17 or React 18 #14

Open
agilgur5 opened this issue Jun 15, 2022 · 0 comments · May be fixed by #19
Open

Doesn't work with React 17 or React 18 #14

agilgur5 opened this issue Jun 15, 2022 · 0 comments · May be fixed by #19

Comments

@agilgur5
Copy link

agilgur5 commented Jun 15, 2022

Problem

When using React 17 or React 18, findInstance returns false. The current algorithm seems to only support React 16.

Reproduction

I've created a minimal reproduction environment on CodeSandbox here.
This uses React 17 and returns false. Upgrading to React 18 will have the same issue of returning false.
Downgrading to React 16, however, will make findInstance work.

I tried using this with React Testing Library as mentioned in the docs, but was unfortunately unable to do so.

I was able to get something working with React refs instead though, but thought I'd file an issue anyway.

Small backstory

I was trying to get this working for testing one of my libraries, react-signature-canvas, which needs to use instance methods as the Canvas API is an imperative API.

Per agilgur5/react-signature-canvas#64 (review), Enzyme has no official support for React 17 (enzymejs/enzyme#2429) or React 18 (enzymejs/enzyme#2524) yet, which has created a big blocker in the community and a shift to using React Testing Library (RTL).
RTL, however, is a pretty different library (more an integration testing library than a unit testing one like Enzyme, plus many other differences), and doesn't even support using instance methods, so this has been a pretty difficult shift in the community.
In agilgur5/react-signature-canvas#64 (comment), I found your blog post and so thought to use this library to bridge the gap therein.

I was able to use the unofficial, partial adapter for React 17 to stick with Enzyme for a bit, but there's no such workaround for React 18.
So I decided to try to get RTL with this library working in agilgur5/react-signature-canvas#76 (comment), and unfortunately hit upon this issue.

Fortunately, I was able to workaround this by using refs (see agilgur5/react-signature-canvas#88), but thought I should file this issue nonetheless for community awareness or possible future support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant