@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
22 lines • 680 B
JavaScript
import * as React from "react";
export const ItineraryContext = /*#__PURE__*/React.createContext({
setWidths: () => {},
calculatedWidth: 0
});
export const ItineraryProvider = ({
children
}) => {
const [widths, setWidths] = React.useState([70]);
const [calculatedWidth, setCalculatedWidth] = React.useState(0);
React.useEffect(() => {
setCalculatedWidth(Math.max(...widths));
}, [widths]);
const value = React.useMemo(() => ({
setWidths,
calculatedWidth
}), [calculatedWidth]);
return /*#__PURE__*/React.createElement(ItineraryContext.Provider, {
value: value
}, children);
};
export const useWidth = () => React.useContext(ItineraryContext);