0
を反応させることコンバートconstが、私はクラスにこのコードを変更することができますどのようにクラス
<Switch>
<Route exact path="/" component={About} />
<Route exact path="/login" component={Login} />
<PrivateRoute path="/protected" component={Home}/>
<Route component={NotMatch} />
</Switch>
しかし、私はに変更する必要があります私がMobXを使っているので、クラス。このような
何か:
@inject('store')
@observer
export default class PrivateRoute extends Component {
constructor (props) {
super(props)
this.store = this.props.store
}
render() {
return (
<div>
</div>
)
}
}
ありがとう!
すべてが正常に動作していますが、へのconstを追加する必要があります:{コンポーネント、...残り} = this.props。 – chemitaxis
何が残りますか? :)ありがとう! – chemitaxis
ああ、constを忘れて、ありがとう! '... rest'は' this.props'オブジェクトの残りの部分を残りのオブジェクトに置きます。 [このリンク](https://babeljs.io/docs/plugins/transform-object-rest-spread/)をご覧ください。 – HosseinAgha