question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed prop type: Invalid prop `fontFamily` of type `object` supplied to `Text`, expected `string`.

See original GitHub issue

Environment

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Trancevercommented, Nov 18, 2019

I’ve added section regarding fonts to the migration guide.

1reaction
gluonscommented, Nov 11, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found