dbstn9135
dbstn9135

Reputation: 51

TypeError: Cannot read property 'allowFontScaling' of undefined, js engine: hermes

I am experiencing the following error after upgrading the expo sdk version to 51.

The errors are

  1. TypeError: Cannot read property 'allowFontScaling' of undefined, js engine: hermes

  2. Invariant Violation: "main" has not been registered. This can happen if:

enter image description here

So I wrote the code on the App.js and it's not working at all. What should I do? `

Text.defaultProps = {
  ...(Text.defaultProps || {}),
  allowFontScaling: false,
};
TextInput.defaultProps = {
  ...(TextInput.defaultProps || {}),
  allowFontScaling: false,
};

enter image description here

Upvotes: 5

Views: 972

Answers (1)

Usman Zafar
Usman Zafar

Reputation: 1

I had the same issue. For me it was a dependency issue. One of the libraries I was using is not handling 'allowFontScaling' correctly. In order to figure out which library is causing the issue, I did the following:

  1. First, check the error log to see which component is the problem child (see screenshot)

  2. My log is showing some issue with "react-native-button"

Note: If you are using this library in your app then simply update it to the latest version, uninstall it, or patch it and you're done 🎉

In my case, I am not using this component at all in my app, so it likely means that one of my dependencies is using "react-native-button" as a sub-dependency. So you move onto the next step

  1. run the following:

yarn why react-native-button

This will tell you which library is using the problem code (for me it was react-native-star-rating).

info Reasons this module exists
   - "react-native-star-rating" depends on it
   - Hoisted from "react-native-star-rating#react-native-button"

  1. At this point, you can either update the react-native-star-rating library version, create a patch, or in my case just delete it and use something else because it hasn't been updated in over 7 years

Upvotes: 0

Related Questions