我们如何在多个选项卡(页面)中使用相同的状态? [英] How can we use the same state across multiple tabs (pages)?

查看:23
本文介绍了我们如何在多个选项卡(页面)中使用相同的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个页面,它是一个带有一系列设置(过滤器、时间范围等)的交互式图表.我想将它们存储在应用程序状态中,因为某些设置可能会被另一个页面上的其他组件使用,但是现在如果我单击任何其他选项卡并返回上一个选项卡,则该页面会显示初始状态(图表消失,过滤数据消失,日期范围显示默认值,下拉列表也显示默认值).并且状态也显示 null.

I have a page in my application that is an interactive chart with a bunch of settings (filters, time ranges, etc). I'd like to store them in-app state because some of the settings may be used by other components on another page, but right now if I click on any other tab and come back to the previous tab then the page shows the initial state(chart is gone, filtered data gone, date range showing the default value, dropdowns shows default ass well). And the state is also showing null.

推荐答案

你的一些状态管理库.与 React 一起使用的最流行的一种是 redux.

You some library for state management. The most popular one that's used with React is redux.

https://redux.js.org/introduction

这篇关于我们如何在多个选项卡(页面)中使用相同的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆