前提・実現したいこと
親と子クラスを定義(extends)して使用したいのですがconstructor内でエラーが発生してしまう。また、以下がよく理解できていないため教えてください。
export default withStyles(styles)(Parent);
発生している問題・エラーメッセージ
TypeError: Unable to get property '64a55d578f856d258dc345b094a2a2b3' of undefined or null reference
該当のソースコード
【Parent.js】 import React from 'react'; import { withStyles } from 'material-ui/styles'; const styles = { root: { backgroundColor: 'red', }, }; class Parent extends React.Component { constructor(props){ super(props); } render () { return <div className={this.props.classes.root} />; } } export default withStyles(styles)(Parent); 【Child.js】 import Parent from './Parent'; class Child extends Parent { constructor(props){ super(props); } } export default Child; 【index.js】 import React from 'react'; import Child from './Child'; ReactDOM.render(<Child/>, document.getElementById('root'));
試したこと
親と子のconstructorを削除すると発生しない。
export default Parent;に変更すると発生しない。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/10 03:55