我对状态和redux用例有点困惑,是否有关于这类事情的“最佳思考方式”。
这是一个例子:
this.state = {
url: this.switch(location.pathname),
};
//listen on url change
history.listen((location, action) => {
//set url
this.setState({
url: this.switch(history.location.pathname),
});
});
历史来自外部文件(作为帮助者):
import { createBrowserHistory } from 'history';
export const history = createBrowserHistory();
渲染:
<Dialog message={this.state.url}/>
我想知道url应该在我的Redux商店吗?还是应该作为一个州?
如果有人有关于主题的链接,想法或任何想法,因为我不知道在redux中应该是什么以及应该只在我的组件中保留什么。
注意:我知道在这个例子中我不需要redux,但我正在努力理解它背后的想法。