0.0.0 • Published 7 years ago

react-outsider v0.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

react-outsider

A component for observing clicks outside an element

WIP

Usage

import Outsider from "react-outsider";

export default class extends React.Component {
  constructor() {
    super();
    this.state = { contentShown: false }
  }

  render() {
    return this.state.contentShown ? (
      <Outsider
        onOutsideClick={
          this.setState(({ contentShown }) => ({
            contentShown: !contentShown
          }))
        }
      >
        Some content
      </Outsider>
    ) : (
      <div />
    )
  }
}

License

MIT, Michael Chan