【问题标题】:TypeError: undefined is not an object (evaluating '_reactNative.Stylesheet.create') in react nativeTypeError: undefined is not an object (evaluate '_reactNative.Stylesheet.create') in react native
【发布时间】:2020-10-22 16:47:38
【问题描述】:

我正在用 react native 制作一个项目,我已经安装了它的所有依赖项,但是当我运行它显示的代码时

TypeError: undefined is not an object (evaluating '_reactNative.Stylesheet.create')

下面还有这个

  • node_modules/react-native/Libraries/LogBox/LogBox.js:148:8 in 注册错误

  • node_modules/react-native/Libraries/LogBox/LogBox.js:59:8 in 错误实现

  • node_modules/react-native/Libraries/LogBox/LogBox.js:33:4 in console.error

  • node_modules/expo/build/environment/react-native-logs.fx.js:27:4 出错

  • node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException

  • node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException

  • node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError

  • ErrorUtils.setGlobalHandler$argument_0 中的

    node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:9:32

  • tryCatch 中的node_modules/regenerator-runtime/runtime.js:63:36

  • 调用中的node_modules/regenerator-runtime/runtime.js:293:29

  • tryCatch 中的node_modules/regenerator-runtime/runtime.js:63:36

  • 调用中的node_modules/regenerator-runtime/runtime.js:154:27

  • node_modules/regenerator-runtime/runtime.js:164:18 in PromiseImpl.resolve.then$argument_0

  • node_modules/react-native/node_modules/promise/setimmediate/core.js:37:13 在 tryCallOne 中

  • node_modules/react-native/node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0

  • node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer

  • node_modules/react-native/Libraries/Core/Timers/JSTimers.js:181:14 in _callImmediatesPass

  • node_modules/react-native/Libraries/Core/Timers/JSTimers.js:441:30 in callImmediates

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:387:6 在 __callImmedates

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:6 在 __guard$argument_0

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 在 __guard

  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:4 在flushedQueue中

  • [本机代码]:flushedQueue 中为空
  • [本机代码]:invokeCallbackAndReturnFlushedQueue 中为空

起初它说的是我修复的一个函数,但我不明白它在哪里引用未定义的对象,如果有人能找到它正在谈论的文件或函数,那就太好了。

【问题讨论】:

  • 能否分享代码的minimal reproducible example 而不是错误?
  • 一个原因可能是您输入了 Stylesheet 而不是 StyleSheet
  • evolution box 我想这就是你的意思我不知道什么是最小可重现的例子,但我认为就是这样。我在 7 个文件中的 6 个文件中都有相同的内容,因此从最后一个错误来看,我认为它可能来自其中一个文件。 const Explore = () => { return( hello ) }; const 样式 = Stylesheet.create({});
  • Gurupsan Giritharan 好的,我会检查一下,感谢您指出这一点!

标签: javascript react-native npm


【解决方案1】:

请尝试这样的方法

const styles = StyleSheet.create({ 
  _container: { 
    flex: 1, 
    backgroundColor: 'blue', 
    alignItems: 'center', 
    justifyContent: 'center' 
  }, 
  get container() { 
    return this._container; 
  }, 
  set container(value) { 
    this._container = value; 
  }, 
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-13
    相关资源
    最近更新 更多