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