@kiwicom/smart-faq
Version:
Smart FAQ
39 lines (30 loc) • 823 B
JavaScript
// @flow
import * as React from 'react';
import { graphql, createFragmentContainer } from 'react-relay';
import type { BookingInfo_leg } from './__generated__/BookingInfo_leg.graphql';
type Context = {|
onLoad: (upcomingLeg: ?BookingInfo_leg) => void,
|};
const bookingInfoContext: React.Context<Context> = React.createContext({
onLoad: (upcomingLeg: ?BookingInfo_leg) => {}, // eslint-disable-line no-unused-vars
});
type Props = {
leg: ?BookingInfo_leg,
};
const BookingInfo = ({ leg }: Props) => (
<Consumer>{({ onLoad }) => onLoad(leg)}</Consumer>
);
export const { Consumer, Provider } = bookingInfoContext;
export default createFragmentContainer(
BookingInfo,
graphql`
fragment BookingInfo_leg on Leg {
arrival {
time
}
departure {
time
}
}
`,
);