import React from "react";
import useSelectionControl from "../../custom-hooks/useSelectionControl";
export default function useSelect(props, reducer) {
  const [selectedValue, onChange] = useSelectionControl(props, reducer);
  let activeValue = null;
  React.Children.map(props.children, (option, i) => {
    if (option.props.value === selectedValue) {
      activeValue = option.props.children;
    }
  });
  return [selectedValue, onChange, activeValue];
}