UNPKG

@kiwicom/smart-faq

Version:

38 lines (27 loc) 837 B
// @flow strict import * as React from 'react'; import LogContext from '@kiwicom/nitro/lib/services/log/context'; import type { Context as LogContextType } from '@kiwicom/nitro/lib/services/log/context'; import type { Event } from '@kiwicom/nitro/lib/records/Event'; type Data = {| +onClick: () => void, |}; type Props = {| +event: Event, +props?: { [string]: string | boolean | number, ... }, +children: (data: Data) => React.Node, |}; class LogClick extends React.Component<Props> { context: LogContextType; static contextType = LogContext; handleLogClick = () => { const { event, props } = this.props; const { log } = this.context; log(event, props ?? {}); }; render() { const { children } = this.props; return children({ onClick: this.handleLogClick }); } } export default LogClick;