Skip to content

Feature: emulate "Text strings must be rendered within a component." error #1032

@mdjastrzebski

Description

@mdjastrzebski

Describe the Feature

React Native renderer throws error when string is rendered outside of Text component, e.g. directly under View 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 of Text 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

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