microsoft / microsoft/react-native-windows
Improvement on Error Messages for YGValues
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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