Add note that shallowRenderer.createRenderrer can be used #2646
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! I was following the docs here for Shallow rendering, and I was using it in a project with typescript. Doing "new ShallowRenderer()" would not even compile in typescript, and tbh I don't disagree with its "expression is not constructible" error message.
You can find more about the error I was having here: facebook/react#17726
I had worried my dear little self for a great deal of time until stumbling across a stack overflow question with an answer that shed a sparkling glimmer of hope on this mystery method: https://stackoverflow.com/questions/45047316/how-to-use-react-test-renderer-shallow-with-typescript/
The purpose of this PR is to add a small note on the ShallowRendering page letting the users of this ShallowRendering api know they can use
ShallowRenderer.createRenderer();
if they receive errors aboutShallowRender
not being a constructible expression.Also, just wanted to throw it out there that maybe the regular, recommended way should be calling the "createRenderer" function. What is the current reasoning for instructing the users to try to instantiate this object with the
new
keyword?Thanks!