Skip to content

Instantly share code, notes, and snippets.

@vojto
Created March 5, 2020 14:07
Show Gist options
  • Save vojto/14818a121b11bcc21f9f7ff6f0aa8dd6 to your computer and use it in GitHub Desktop.
Save vojto/14818a121b11bcc21f9f7ff6f0aa8dd6 to your computer and use it in GitHub Desktop.
import { Text } from 'pixi.js';
import { PixiComponent } from '@inlet/react-pixi';
const FastText = PixiComponent('FastText', {
create: props => new Text(props.text),
applyProps: (instance, oldProps, props) => {
const { x, y, text } = props;
if (x !== oldProps.x || y !== oldProps.y) {
instance.x = x;
instance.y = y;
}
if (text !== oldProps.text) {
instance.text = text;
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment