Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 836 Bytes

Hooks.mdx

File metadata and controls

55 lines (41 loc) · 836 Bytes
name order route
Hooks
2
/hooks

Hooks

React Pixi now support React hooks 🌟

useApp

Access the PIXI.Application in your component

import { useApp } from '@inlet/react-pixi'

function MyComponent () {
  const app = useApp()
  // app => PIXI.Application

  return (
    ...
  )
}

useTick

Bind listener to the PIXI.Application ticker event

import { useTick } from '@inlet/react-pixi'

function MyComponent () {
  useTick(delta => {
    // do something here
  })

  return (
    ...
  )
}

Example:

<iframe height={500} scrolling="no" title="useTick" src="//codepen.io/inlet/embed/EOMBer/?height=300&theme-id=33987&default-tab=result&embed-version=2" frameBorder="no" allowFullScreen={true} style={{ width: '100%' }} />