[Bug] Compilation error with React Native 0.79.x - StyleLength unit() method not found

Open Beginner friendly
#731 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
cpp, react-native
Domain
mobile

Research direction

Start with common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp and reproduce the compilation failure against React Native 0.79.x. Compare the reported Style::Length API usage with the version in that React Native release, then build the relevant native target and verify that the safe-area context package compiles without the error.

Written by the indexing model from the issue text.

Description

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-safe-area-context@4.14.1 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-safe-area-context/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp b/node_modules/react-native-safe-area-context/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp
index 6d94c52..0fe05e5 100644
--- a/node_modules/react-native-safe-area-context/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp
+++ b/node_modules/react-native-safe-area-context/common/cpp/react/renderer/components/safeareacontext/RNCSafeAreaViewShadowNode.cpp
@@ -16,10 +16,10 @@ inline Style::Length valueFromEdges(
     Style::Length edge,
     Style::Length axis,
     Style::Length defaultValue) {
-  if (edge.unit() != Unit::Undefined) {
+  if (!edge.isUndefined()) {
     return edge;
   }
-  if (axis.unit() != Unit::Undefined) {
+  if (!axis.isUndefined()) {
     return axis;
   }
   return defaultValue;

This issue body was partially generated by patch-package.

Dominant language
TypeScript
Stars
2.8k
Forks
259
Avg merge
3d 1h
Merged PRs (30d)
2

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.

More from appandflow/react-native-safe-area-context

All issues in appandflow/react-native-safe-area-context

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.