1

I have a nested inside a in React Native. Is there a way to tell React Native to style all nested Text Elements that are inside a specific (or all) View Element?

<View style={[container.header,container.super]}><Text>overview</Text></View>

I dont want declare style={text.headerText} or similar to every single Text element that is inside the View Element. Maybe there is something like

.container.header > Text { ... }

like it is in classic .css

Ian Vasco
  • 1,280
  • 13
  • 17
PRSHL
  • 1,359
  • 1
  • 11
  • 30

1 Answers1

1

An option could be to create a component

function MyTextComponent(props) {
  return (<Text style={style.myTxtStyle}>{props.children}</Text>);
}

And then just instead of using Text Component use MyTextComponent like this

<MyTextComponent>Some text</MyTextComponent>
Charlie
  • 992
  • 8
  • 19