Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the expected format of fontVariant in react native

Tags:

react-native

I am trying to use fontVariant on a Text style. The documentation says it expects an "array of enum". How does that look like in json? I have tried passing a string, and it works on android is ignored on android, but throws an error on ios:

<Text style={{ fontVariant: 'small-caps' }}>some text</Text>

will throw:

JSON value 'small-caps' of type NSString cannot be converted to NSArray

I am on version 0.53.3 react-native

like image 528
Hugo Silva Avatar asked Jan 28 '23 14:01

Hugo Silva


1 Answers

According to the source PropTypes, it expects an array of strings matching the enum:

<Text style={{ fontVariant: [ 'small-caps' ] }}>some text</Text>
like image 71
Dave Meehan Avatar answered Mar 06 '23 19:03

Dave Meehan