yarn add react-dou react react-dom styled-components # @types/react @types/react-dom @types/styled-components
(
<DouProvider callback={callback}>
<DouFunctionsConsumer>
{({ask}) => {
return (
<button onClick={ask('ハンバーガー食べますか?')}>ハンバーガー食べますか?</button>
);
}}
</DouFunctionsConsumer>
<Dou />
</DouProvider>
)
interface Props {
text: string;
}
class IComponent extends React.Component<
Props & Partial<DouFunctionsProps>,
{a: string}
> {
// @ts-ignore
props: Props & DouFunctionsProps
render() {
return (
<button onClick={this.props.dou.ask('message')}>{this.props.text}</button>
);
}
}
const IComponentWithDou = withDou<Props>(IComponent);
MIT