// @flow strict import * as React from 'react'; type V = { key: string, label: string, arbitrary?: boolean, multiarbitrary?: boolean, ... }; type Group = { options: Array, groupTitle?: React.Node, ... }; export const getFirstOption = (options: Array): V | null => { // pick the first option from the options if (options.length > 0) { return options[0]; } return null; }; export const getFirstOptionFromGroup = ( groupTitleOptions: Array>, ): V | null => { if (groupTitleOptions.length > 0) { const firstGroup = groupTitleOptions[0]; if (firstGroup.options && firstGroup.options.length > 0) { return firstGroup.options[0]; } } return null; };