2017-02-16 37 views
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); 

如何解决此得到的东西?我有没有正确诊断过?

+0

如何导入组件? – janhartmann

+0

'{()=>}'只是一个匿名函数声明,如果您希望将组件渲染,请将其包装在IIFE中:'{(()=>)()}'。当然,你应该避免引入这种不必要的复杂性,所以只需在这里写'' – Igorsvee

+0

@Igorsvee这就是我最初尝试的 - 你指的是另一个尝试,我读到别的地方。 – praks5432

回答

0

当您看到消息“期望字符串(对于内置组件)或类/函数”时。其实,因为你没有输出功能或减速器。请仔细检查。

欢呼!