-
Notifications
You must be signed in to change notification settings - Fork 273
Feature: emulate "Text strings must be rendered within a component." error #1032
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
Comments
Hey @mdjastrzebski, I'd be happy to help, I'll send a pr soon |
@pierrezimmermannbam awesome! Please do :-) |
I've started to work on it, I've completed the first step but I'm having some difficulties for generalizing the behavior. |
@pierrezimmermannbam Indeed finding a proper hook is rather difficult. Maybe we could wrap rendered user component inside 'React.Profiler' which has 'onRender' event that should be called after each render anywhere among its descendants. At this moment the component tree should probably be already updated, but we need to check that. If this works we may also analyze how exactly 'React.Profiler' works in order fine tune that solution. |
@mdjastrzebski using a Profiler worked ! I opened a pr |
Resolved by #1070 |
Describe the Feature
React Native renderer throws error when string is rendered outside of
Text
component, e.g. directly underView
or other native component. It seems that React Test Renderer that we use does not throw a similar error in this situation, which may lead to missed errors that RNTL could capture in tests.This feature would emulate that behaviour by throwing error whenever string value is rendered outside of
Text
component.Possible Implementations
As a first step we could analyse render tree after initial render and look for
string
children
prop that are not children ofText
component.Then we would have to figure out a way to react to subsequent re-renders to trigger the validation again. Maybe a custom
act
wrapper that would invoke the validation.Related Issues
This feature request is based on #556
The text was updated successfully, but these errors were encountered: