Answer the question
In order to leave comments, you need to log in
PureComponent renderer, will it happen?
The main question is described in the title, but there are such clarifications: I
use React { PureComponent }
, MobX, SSR.
The app has a "Refresh" button that runs a forced query to get up-to-date data. Next, after the data has been updated, the component should be re-rendered, for this I have the following tools:
The fetchState decorator
@fetchState(
state => ({ data: state.data }),
actions => ({ done: actions.done }),
)
@observer
and do the following in the component itselfcomponentWillMount() {
if (!this.props.data) {
this.store.load().then((data) => {
this.props.done({ data });
}, (error) => {
console.error('Products not loaded', error);
this.props.done({});
});
} else {
this.store.load(this.props.data);
}
}
componentDidMount() {
this.disposer = reaction(() => subscription.updateInfo, () => this.store.load());
}
componentWillUnmount() {
if (typeof this.disposer === 'function') this.disposer();
}
this.disposer = reaction(() => subscription.updateInfo, () => this.store.load());
says that if there have been changes in updateInfo, then I reload store. In response from this store, I get the information, but it is the same. And there is no renderer. I tried to make the component and the usual inheritance from Component, there is no rerender either. this.store.load()
called, checked. I already decided that everything would be re-rendered when an updated date was received, but doubts arose) Who will say what? this.disposer = reaction(() => subscription.updateInfo, () => this.store.load().then(() => this.forceUpdate()));
, nooo, somehow not right IMHO
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question