UNPKG

@lunit/oui

Version:

Lunit Oncology UI components

18 lines (17 loc) 470 B
/** * * @param defaultTab string | undefined * @param tabs TabConfig[] * @returns string * @description returns the initial value for useState, based on defaultTab. * If default tab is provided and matched, returns that, * else, returns first tab. * */ function findDefaultTab(defaultTab, tabs) { if (defaultTab) { return tabs.find((t) => t.value === defaultTab)?.value ?? tabs[0].value; } return tabs[0].value; } export { findDefaultTab };