How do I measure a custom native component in React Native on Android

Viewed 1666

I want to create a custom native component which renders a single line of text. The length of this text is dynamic and the typeface and size are configurable.

When I place my custom component in a standard <View /> the provided size constraints in View.onMeasure (native) are zero for height and this is MeasureSpec.EXACTLY. Returning any non-zero height in View.onMeasure does nothing.

class App extends React.Component<{}, undefined> {
  render() {
    return (
      <View style={{
          flex: 1,
        }}>
        <CustomComponent />
      </View>
    )
  }
}

How do I allow my custom native view to measure itself and provide this to React Native during measurement and layout?

1 Answers
Related