Hugo Silva
Hugo Silva

Reputation: 6938

What is the expected format of fontVariant in 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

Upvotes: 4

Views: 4420

Answers (1)

Dave Meehan
Dave Meehan

Reputation: 3201

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

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

Upvotes: 8

Related Questions