UNPKG

@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.

23 lines 677 B
import * as React from "react"; export const ItineraryContext = /*#__PURE__*/React.createContext({ setWidths: () => {}, setCalculatedWidth: () => {}, calculatedWidth: 0 }); export const ItineraryProvider = ({ children }) => { const [widths, setWidths] = React.useState([]); const [calculatedWidth, setCalculatedWidth] = React.useState(0); React.useEffect(() => { setCalculatedWidth(Math.max(...widths)); }, [widths]); return /*#__PURE__*/React.createElement(ItineraryContext.Provider, { value: { calculatedWidth, setCalculatedWidth, setWidths } }, children); }; export const useWidth = () => React.useContext(ItineraryContext);