Skip to content

nju33/react-dou

Repository files navigation

React Dou

CircleCI TypeScript react-dou style: styled-components code style: prettier

Install

yarn add react-dou react react-dom styled-components # @types/react @types/react-dom @types/styled-components

by DouFunctionsConsumer

(
  <DouProvider callback={callback}>
    <DouFunctionsConsumer>
      {({ask}) => {
        return (
          <button onClick={ask('ハンバーガー食べますか?')}>ハンバーガー食べますか?</button>
        );
      }}
    </DouFunctionsConsumer>
    <Dou />
  </DouProvider>
)

by withDou

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);

References

License

MIT