0

I have five different tabs, each with a filter where I am filtering data on the basis of parameters. Now

  1. Let's say I am on tab 1 and I filtered the content on the basis of parameters.
  2. Now when I change to tab 2, the filtered data on tab 1 should not be changed and remain same (for comparison purposes). So basically the filtered state should remain same while switching tabs.

I have used no filter module or library for this. How do I implement this in my react application?

Vinay Singh
  • 463
  • 2
  • 9
  • 16
  • If you keep the data in each Tab component, each time you change the Tab it will get unmounted and a new one is mounted and hence filtering is not persisted. You need to lift the state up to their parent. Check this answer https://stackoverflow.com/questions/46594900/reactjs-lifting-state-up-vs-keeping-a-local-state/47349693#47349693 and https://stackoverflow.com/questions/38394015/how-to-pass-data-from-child-component-to-its-parent-in-reactjs/38397755#38397755 – Shubham Khatri Feb 22 '18 at 10:50
  • @VinaySingh Handle state separate for each tab. this will maintain data specific to tab – Javed Shaikh Feb 22 '18 at 11:09

0 Answers0