Failed prop type: Invalid prop `fontFamily` of type `object` supplied to `Text`, expected `string`.
See original GitHub issueEnvironment
This bug is found on the IPhone 7 device.
Description
I noticed that for the theme, we need to provide the fonts in the following format:
...
ios: {
regular: {
fontFamily: 'System',
fontWeight: '400' as '400',
},
medium: {
fontFamily: 'System',
fontWeight: '500' as '500',
},
light: {
fontFamily: 'System',
fontWeight: '300' as '300',
},
thin: {
fontFamily: 'System',
fontWeight: '100' as '100',
},
},
....
Then I took a peek at the code for those typography components. Let’s take the Text
component as an example:
return (
<NativeText
{...rest}
ref={(c) => {
this._root = c;
}}
style={[
{
fontFamily: theme.fonts.regular,
color: theme.colors.text,
textAlign: 'left',
writingDirection,
},
style,
]}
/>
);
Here theme.fonts.regular is an object obviously, which cannot be assigned to the key fontFamily
. After I changed it to ...theme.fonts.regular
, everything works as expected.
This bug also appears in the other components under Typography.
Reproducible Demo
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Failed prop type: Invalid prop `value` of type `number ...
I'm reading the doc of TextInput and it seems that onChange and onChangeText both return a string, is there any other callback that...
Read more >Invalid prop 'value' of type 'object' supplied to 'TextInput' React ...
Coding example for the question Failed prop type: Invalid prop 'value' of type 'object' supplied to 'TextInput' React Native-React Native.
Read more >Invalid Prop Types: Prop.Style Key Fontsize Supplied To View
Describe the bug Any input in either form field first throws the warning Warning: Failed prop type: Invalid prop value of type number...
Read more >RenderHTMLProps | React Native Render HTML
Props for the component. ... ( contentWidth : number , tagName : string ) => number ; ... Defined in packages/render-html/src/shared-types.ts. Props...
Read more >type check failed for prop "items". expected array, got string ...
That is probably because Vuetify's v-data-table component expects to receive an array of objects, while you are only providing an array of string....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve added section regarding fonts to the migration guide.
Me too. Face this error after upgrade to version 3. Error with the same code that I use in version 2. (I didn’t use components that affected by breaking changes)
No any
fontFamily
noticed in Migration guide.