How to use the avataaars.OptionContext function in avataaars

To help you get started, we’ve selected a few avataaars 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 fangpenlin / avataaars-generator / src / components / Renderer.tsx View on Github external
),
  avatarStyle: {
    type: UrlQueryParamTypes.string,
    updateType
  }
}

export class Renderer extends React.Component {
  static childContextTypes = {
    optionContext: PropTypes.instanceOf(OptionContext)
  }
  static defaultProps = {
    avatarStyle: AvatarStyle.Circle
  }

  private optionContext: OptionContext = new OptionContext(allOptions)

  getChildContext () {
    return { optionContext: this.optionContext }
  }

  componentWillReceiveProps (nextProps: Props) {
    this.updateOptionContext(nextProps)
  }

  componentWillMount () {
    this.updateOptionContext(this.props)
  }

  componentDidMount () {
    const anyWindow = window as any
    setTimeout(() => {
github fangpenlin / avataaars-generator / src / components / Main.tsx View on Github external
export class Main extends React.Component {
  static childContextTypes = {
    optionContext: PropTypes.instanceOf(OptionContext)
  }
  static defaultProps = {
    avatarStyle: AvatarStyle.Circle
  }

  state = {
    displayComponentCode: false,
    displayComponentImg: false
  }

  private avatarRef: Avatar | null = null
  private canvasRef: HTMLCanvasElement | null = null
  private optionContext: OptionContext = new OptionContext(allOptions)

  getChildContext () {
    return { optionContext: this.optionContext }
  }

  componentWillReceiveProps (nextProps: Props) {
    this.updateOptionContext(nextProps)
  }

  componentWillMount () {
    this.optionContext.addValueChangeListener(this.onOptionValueChange)
    this.updateOptionContext(this.props)
  }

  componentDidMount () {
    const anyWindow = window as any

avataaars

React component for avataaars

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis