I've recently implemented dark mode into my app, but having an issue with an error when building the npm package with npm build
. The code works, but is there a way or a reason to remove this error?
React Native Docs: Appearance
Error
src/ContactActionSheet.tsx:3:10 - error TS2305: Module '"react-native"' has no exported member 'Appearance'.
3 import { Appearance, Dimensions, StyleSheet, Text, View, Linking, TouchableOpacity } from 'react-native';
JSX
// Imports: Dependencies
import { Appearance, Dimensions, StyleSheet, Text, View, Linking, TouchableOpacity } from 'react-native';
// Dark Mode
const colorScheme = Appearance.getColorScheme();
The issue was with the npm package @types/react-native
needing to be updated.
Thanks for following up with a response. After checking what version I was on, I discovered I didn't even have the @types/react-native
module added. Once I added that, my issue was resolved. Strange how if you start a project with TypeScript, it is not guaranteed to even have that dependency.
I tried npm install --save @types/react-native
but it didn't work. I had to add @latest
at the end on order to get a proper update of the version. try this command npm install --save @types/react-native@latest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With