0.0.1 • Published 4 years ago

@xhkz/react-seat-map v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

react-seat-map

react interactive seat map component

NPM JavaScript Style Guide

Online Demo

https://xinit.me/react-seat-map/

Install

npm install --save react-seat-map

yarn add react-seat-map

Usage

import React from 'react'
import axios from 'axios'
import SeatMap from 'react-seat-map'

export default class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      sections: [],
      seats: []
    }
  }

  handleClick(data) {
    console.log(data)
  }

  async getData() {
    const resp = await axios.get('/seatmap.json')
    this.setState({
      sections: resp.data.sections,
      seats: resp.data.seats
    })
  }

  componentDidMount() {
    this.getData()
  }

  render() {
    return (
      <div>
        <SeatMap sections={this.state.sections} seats={this.state.seats} seatClick={this.handleClick} />
      </div>
    )
  }
}

License

MIT © xhkz