score:0

move condition logic to inside another hook:

const usedashboardorplotter = (condition: boolean) => {
  const {statedashboard, actiondashboard} = usedashboard();
  const {stateplotter, actionplotter} = useplotter();

  return condition ? {statedashboard, actiondashboard} : {stateplotter, actionplotter}
}

const sidebar = () => {
  ... condition
  const {state, action} = usedashboardorplotter(condition);
  return (
    <div>...</div>
  )
}

score:0

you can use like this in same component.

const {state: plottstate, action: plottaction} = useplotter();
const {state: dashboardstate, action: dashboardaction} = usedashboard();

now use plottstate, plottaction, dashboardstate, dashboardaction


Related Query

More Query from same tag