0
所以我想用Redux的反应,我不断收到这个错误在模拟器使用本机作出反应与终极版
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
和
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
ExceptionsManager.js:63Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
我已经分离出的问题降到这个
<Provider store={store}>
<App />
</Provider>
当我删除提供程序的应用程序渲染的内容(让我们只是说他们是一个简单的'Hello World'文本组件)。当我把它放回去时,它不会。
我知道在较旧版本的反应中,这是一个问题,但我在15.4.0
。
但是为了以防万一,我试图做这样的
// wrapper.js
const wrapper =() => {
return (
<Provider store={store}>
{() => <App />}
</Provider>
);
}
// index
AppRegistry.registerComponent('BasketballAndroidFrontend',() => wrapper);
如何解决此得到的东西?我有没有正确诊断过?
如何导入组件? – janhartmann
'{()=> }'只是一个匿名函数声明,如果您希望将组件渲染,请将其包装在IIFE中:'{(()=> )()}'。当然,你应该避免引入这种不必要的复杂性,所以只需在这里写' ' –
Igorsvee
@Igorsvee这就是我最初尝试的 - 你指的是另一个尝试,我读到别的地方。 – praks5432