microsoft / microsoft/react-native-windows

Improvement on Error Messages for YGValues

Open
#6,864 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: Developer Experience enhancement PR Follow-up Upstream Workstream: Developer Experience
Dominant language
C++
Stars
17.3k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
33

Description

Proposal: Improvement on Error Messages for YGValues

Summary

This request emerged from this PR . Currently, we fire a Red Box error for incorrect YGValue inputs from within NativeUIManager using a RedBox API from ShadowNodeBase. In future, the request would be to improve this solution one of two ways. One option would be to move the RedBox and YellowBox APIs outside of ShadowNodeBase and make them more general and simply accept a ReactContext. The second option (preferred) would be to fire the error from the JS side of things instead of the native side (would require a RN Core change).

Motivation

The motivation for updating the solution to at least option 1 is that having RedBox and YellowBox in ShadowNodeBase isn't very cohesive. It creates a convenience for certain functions in certain parts of ViewManagers that cannot be used generically, and isn't part of the ViewManager interface.

The motivation for updating the solution to option 2 is that currently on all platforms the callstack shown in the RedBox error doesn't provide particularly useful information to identify the component causing the issue. This is because the error is fired from within the native code. If we added a process function for the appropriate style properties in Libraries\Components\View\ReactNativeViewViewConfig.js. we could fire the RedBox error from the JS side of things and the developer would get better context on where in there JS files the entered YGValue's format is incorrect. Since this would be a core change it would potentially improve the error for all the platforms.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing NativeUIManager and ShadowNodeBase, then inspect Libraries\Components\View\ReactNativeViewViewConfig.js and the referenced PR. Compare moving RedBox and YellowBox handling to a ReactContext with validating YGValues on the JavaScript side; done means an agreed approach that improves error ownership and callstack context.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, react-native
Domain
desktop-dev, developer-experience, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.