I'm using React with typescript and Material UI as framework. If you choose a line in the dataset table, the context "chosenDataset" is set, but crashes the app because it re-renders too many times. I want that it dynamically adds tabs and panels with data from an API. It gets the data(here the mappings aka the SelectionMatrix) but it is stuck on the first one. I guess because it doesn't get further because of the re-rendering. What is triggering the re-rendering or calling the hook. And how do I change that? I tried to use useMemo to prevent the re-rendering, but it's not possible to use it with hooks.
In case that it helps, here is the main component causing the error: https://codesandbox.io/s/fervent-antonelli-epytmz?file=/src/mappingTabs.tsx