pixijs / pixi-react

Write PIXI apps using React declarative style
https://pixijs.io/pixi-react/
MIT License
2.39k stars 180 forks source link

Support fallback to Canvas #252

Closed inlet closed 4 years ago

inlet commented 4 years ago

Related issue: #126

Support fallback to Canvas out of the box

Because react-pixi imports pixi.js directly it's quite hard to configure your project with pixi-legacy. You need to alias pixi.js to pixi.js-legacy in your bundler/babel config. It can be a bit frustrating, especially if you're using a project scaffold tool like CRA and are forced to eject your project because of this.

Now here's the solution:

Install pixi legacy:

npm install pixi.js-legacy

Use the legacy export:

import { Stage } from '@inlet/react-pixi/legacy';

now this works:

<Stage options={{ forceCanvas: true }}>...</Stage>