I just started rewriting my existing react-native project from js to typescript.To disable font scaling, I set Text.defaultProps.allowFontScaling
to false
at the beginning of App.js and it worked well.
import React from 'react';import { Text } from 'react-native';...if (Text.defaultProps == null) Text.defaultProps = {};Text.defaultProps.allowFontScaling=false; export default function App () { . . .}
When I changed from App.js
to App.tsx
and ran tsc
, I get following typescript error:
App.tsx:16:10 - error TS2339: Property 'defaultProps' does not exist on type 'typeof Text'.16 if (Text.defaultProps == null) Text.defaultProps = {};
I tried to search similar issues and typescript documents but failed. How can I solve this error?