2017-06-04 73 views
0

我試圖用react-native和redux創建一個計數器,但是我收到了錯誤Expected a component class, got [object Object]將react-native與redux連接起來的問題

這是我index.android.js

import React, { Component } from 'react'; 
import { AppRegistry } from 'react-native'; 

import Root from './src/containers/Root'; 
import configureStore from './configureStore'; 

export default class CounterReactNativeRedux extends Component { 
    render() { 
    return (<Root store={configureStore()} />) 
    } 
} 

AppRegistry.registerComponent('CounterReactNativeRedux',() => CounterReactNativeRedux); 

我的代碼可以發現here

找到了關於這種說法的答案,可能是因爲類名不是大寫,但事實並非如此。

任何任何想法?

回答

1

看看你的Counter.js。您已經在那裏使用了div標籤,這些標籤在React Native中不存在。

因此從React Native導入View標籤並使用它。

import {View} from 'react-native' 

const Counter = ({ value }) => (
    <View>{value}</View> 
); 
+0

這就是我的問題,非常感謝你@亨利克 –