1
我有一個組件通過道具收到store
。所以tslint與製作的Airbnb預設告訴我,我必須聲明PropTypes
店面,所以我說:警告通過商店作爲道具
Root.propTypes = {
store: PropTypes.object.isRequired,
};
但Prop type object is forbidden
。所以我改變了代碼:
Root.propTypes = {
store: PropTypes.objectOf(PropTypes.object).isRequired,
};
但是,現在的瀏覽器控制檯說我:
Warning: Failed prop type: Invalid prop `store.dispatch` of type `function` supplied to `Root`, expected `object`.
在我index.js
我:
const store = configureStore();
ReactDOM.render(
<Root store={store} />,
document.getElementById('root'),
);
我怎樣才能解決呢?
'PropTypes.object.isRequired'是有效的。 'Prop type object is forbidden'的錯誤信息是從哪裏觸發的? – ganesshkumar
從'airbnb'棉絨 – FacundoGFlores