Expo環境でreact-native-dark-modeというライブラリを使用する際にエラーが起きます。ReactNativeのバージョンが62.0以降なら対応しているはずなのですが、私の環境(Expo SDK 42.0.0)でエラーが発生します。解決方法があればお願いします。
json
1// package.json 2{ 3 "main": "node_modules/expo/AppEntry.js", 4 "scripts": { 5 "start": "expo start", 6 "android": "expo start --android", 7 "ios": "expo start --ios", 8 "web": "expo start --web", 9 "eject": "expo eject" 10 }, 11 "dependencies": { 12 "expo": "~42.0.1", 13 "expo-status-bar": "~1.0.4", 14 "react": "16.13.1", 15 "react-dom": "16.13.1", 16 "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz", 17 "react-native-dark-mode": "^0.2.2", 18 "react-native-web": "~0.13.12" 19 }, 20 "devDependencies": { 21 "@babel/core": "^7.9.0" 22 }, 23 "private": true 24}
js
1// App.js 2import { StatusBar } from 'expo-status-bar'; 3import React from 'react'; 4import { StyleSheet, Text, View } from 'react-native'; 5import { useDarkMode } from 'react-native-dark-mode'; 6 7export default function App() { 8 9 const isDarkMode = useDarkMode(); // 追記箇所 10 11 return ( 12 <View style={styles.container}> 13 <Text>Open up App.js to start working on your app!</Text> 14 <StatusBar style="auto" /> 15 </View> 16 ); 17} 18 19const styles = StyleSheet.create({ 20 container: { 21 flex: 1, 22 backgroundColor: '#fff', 23 alignItems: 'center', 24 justifyContent: 'center', 25 }, 26}); 27
terminal
1// エラーログ 2TypeError: null is not an object (evaluating '_nativeModule.NativeModule.initialMode') 3at node_modules\react-native\Libraries\LogBox\LogBox.js:148:8 in registerError 4at node_modules\react-native\Libraries\LogBox\LogBox.js:59:8 in errorImpl 5at node_modules\react-native\Libraries\LogBox\LogBox.js:33:4 in console.error 6at node_modules\expo\build\environment\react-native-logs.fx.js:27:4 in error 7at node_modules\react-native\Libraries\Core\ExceptionsManager.js:104:6 in reportException 8at node_modules\react-native\Libraries\Core\ExceptionsManager.js:171:19 in handleException 9at node_modules\react-native\Libraries\Core\setUpErrorHandling.js:24:6 in handleError 10at node_modules\expo-error-recovery\build\ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0 11at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch 12at node_modules\regenerator-runtime\runtime.js:294:29 in invoke 13at node_modules\regenerator-runtime\runtime.js:63:36 in tryCatch 14at node_modules\regenerator-runtime\runtime.js:155:27 in invoke 15at node_modules\regenerator-runtime\runtime.js:165:18 in PromiseImpl.resolve.then$argument_0 16at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne 17at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0 18at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer 19at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass 20at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates 21at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates 22at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0 23at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard 24at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue 25at [native code]:null in flushedQueue 26at [native code]:null in invokeCallbackAndReturnFlushedQueue
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。