-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow custom app to be a function #168
Comments
@sheerun canvas is not created by react-pixi-fiber if you pass your own app – it is created by PIXI.Application not by react so it doesn't make sense for React to inject it to DOM, you can easily do it on your own using |
@michalochman I'm afraid it is created by react-pixi-fiber: https://github.com/michalochman/react-pixi-fiber/blob/master/src/hooks.js#L68-L69 |
No, it is not: The main problem with your proposed solution is that app would be created every time |
Let's leave this issue open as this is an interesting idea generally. |
@michalochman I've implemented proof of concept like this: And it seems to work when used like this (app is created only one time): function App() {
return <Stage
createApp={options => {
console.log('Creating app with options:', options)
return new PIXI.Application(options)
}}
options={{
width: 800,
height: 500,
resolution: window.devicePixelRatio || 1,
autoDensity: true,
clearBeforeRender: false,
backgroundColor: 0xFFFFFF
}}
>
<TextInput
x={250}
y={200}
width={100}
/>
</Stage>
} You can try it with yarn and:
|
Another API that could be implemented is: function App({ width, height }) {
const app = usePixiApp(options => {
console.log('Creating app with options:', options)
return new PIXI.Application({
width: width,
height: height,
resolution: window.devicePixelRatio || 1,
autoDensity: true,
clearBeforeRender: false,
backgroundColor: 0xFFFFFF,
...options
})
}, [width, height])
return <Stage app={app}>
<TextInput
x={250}
y={200}
width={100}
/>
</Stage>
} |
Description
Currently it's possible to pass custom app, but it's not possible to attach it to underlying canvas created by react-pixi-fiber. Ideally this libarry would allow provided app to be function that accepts canvas reference, like so:
Unless there's another way I don't know about :)
The text was updated successfully, but these errors were encountered: