我正在构建一个 React + Mobx 应用程序,我有一个组件不渲染任何内容,因为它全部基于 3rd 方地图 API,但我需要对一些商店属性更改做出反应:
componentDidMount() {
mapApi.doSomething(this.props.store.value)
}
componentWillReact() {
mapApi.doSomething(this.props.store.value)
}
render () {
//workaround to make componentWillReact trigger
console.log(this.props.store.value)
return null
}
有没有一种优雅的方式来实现这一点?