in src/components/BlockSwitcher/index.tsx [33:48]
const getActiveIndex = function(
children: React.ReactElement[],
tabOrder: string[],
) {
// The index we want to be active is the first one in priority order (`ctx.tabOrder`)
// that is also one of the options (i.e., in `children`).
const nameToIndexMap = {};
children.forEach((node, index) => {
nameToIndexMap[node.props.name] = index;
});
for (const tabName of tabOrder) {
if (tabName in nameToIndexMap) {
return nameToIndexMap[tabName];
}
}
};