Skip to content
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

New arch doesn't render React Native components inside SVG #2519

Open
pnthach95 opened this issue Oct 29, 2024 · 1 comment
Open

New arch doesn't render React Native components inside SVG #2519

pnthach95 opened this issue Oct 29, 2024 · 1 comment

Comments

@pnthach95
Copy link

pnthach95 commented Oct 29, 2024

Description

I'm sorry if it is a duplicate, first time use new arch because of RN 0.76

<PillInforBox>
  <View style={styles.sectionContainer}>
    <Text style={styles.sectionTitle}>top text</Text>
    <Text style={styles.sectionTitle}>BOTTOM TEXT</Text>
  </View>
</PillInforBox>
const PillInforBox = ({children}) => {
  return (
    <Svg>
      ...
      {children}
    </Svg>
  )
}

I code like this and it works in old arch until now (RN 0.76). I tested with

RN 0.75 RN 0.76
Old arch OK OK
New arch Fail Fail

New arch
Screenshot 2024-10-29 at 1 58 40 PM

Old arch
Screenshot 2024-10-29 at 2 10 11 PM

Steps to reproduce

  1. Clone and build reproduction in new arch
  2. Disable new arch and rebuild
  3. There is rn75 branch if you want to test

Snack or a link to a repository

https://github.com/pnthach95/rn76

SVG version

15.8.0

React Native version

0.76.0

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Fabric (New Architecture)

Build type

Debug app & dev bundle

Device

None

Device model

No response

Acknowledgements

Yes

@jakex7
Copy link
Member

jakex7 commented Oct 30, 2024

Hi @pnthach95,

Thanks for bringing this up! There's indeed an issue with the new architecture when it comes to Yoga layouting. It's part of a broader issue we're working on. In fact, the components are being rendered, but they're positioned far below the SVG, and it's white text on a white background, which makes them appear as not rendered.

As a temporary workaround, you can change the order of children so that {children} is the first child of the Svg component, like this:

const PillInforBox = ({children}) => {
  return (
    <Svg>
      {children}
      ...
    </Svg>
  )
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants