How to use the mobx-react.propTypes.arrayOrObservableArray function in mobx-react

To help you get started, we’ve selected a few mobx-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github knoopx / plex-music / src / ui / virtual-list / index.jsx View on Github external
import PropTypes from 'prop-types'
import React from 'react'
import { observable, computed, action, runInAction } from 'mobx'
import { propTypes, observer } from 'mobx-react'

@observer
export default class VirtualList extends React.Component {
  static propTypes = {
    items: propTypes.arrayOrObservableArray.isRequired,
    itemHeight: PropTypes.number.isRequired,
    renderItem: PropTypes.func.isRequired,
    bufferSize: PropTypes.number.isRequired,
  }

  static defaultProps = {
    bufferSize: 0,
  }

  @observable scrollTop = 0
  @observable clientHeight = 0

  componentDidMount() {
    this.setScrollTop(this.container.scrollTop)
    this.setClientHeight(this.container.clientHeight)
    window.addEventListener('resize', this.onResize)
github knoopx / crypto-watch / src / ui / virtual-list.jsx View on Github external
import PropTypes from 'prop-types'
import React from 'react'
import { observable, computed, action, runInAction } from 'mobx'
import { propTypes, observer } from 'mobx-react'

@observer
export default class VirtualList extends React.PureComponent {
  static propTypes = {
    items: propTypes.arrayOrObservableArray.isRequired,
    itemHeight: PropTypes.number.isRequired,
    renderItem: PropTypes.func.isRequired,
    bufferSize: PropTypes.number.isRequired,
  }

  static defaultProps = {
    bufferSize: 10,
  }

  @observable scrollTop = 0
  @observable clientHeight = 0

  componentDidMount() {
    this.setScrollTop(this.container.scrollTop)
    this.setClientHeight(this.container.clientHeight)
    window.addEventListener('resize', this.onResize)
github knoopx / plex-music / src / ui / list / index.jsx View on Github external
import PropTypes from 'prop-types'
import React from 'react'
import { propTypes, observer } from 'mobx-react'

@observer
export default class List extends React.Component {
  static propTypes = {
    items: propTypes.arrayOrObservableArray.isRequired,
    selected: PropTypes.object,
    renderItem: PropTypes.func.isRequired,
    onSelect: PropTypes.func,
  }

  static defaultProps = {
    onSelect: () => {},
  }

  renderItem(item, index) {
    const isActive =
      this.props.items.includes(item) && this.props.selected === item
    return (
      <div> this.props.onSelect(item)}&gt;
        {this.props.renderItem(item, index, isActive)}
      </div>
github JoeRoddy / firestation / src / components / Navbar.js View on Github external
return (
        <a href="#"> setCurrentDb(db)}
          key={index}
        &gt;
          {db.title}
        </a>
      );
    })}
  
);

DatabaseList.propTypes = {
  databases: propTypes.arrayOrObservableArray,
  setCurrentDb: PropTypes.func
};