score:0
Check this new WebComponent to integrate Phaser with any other framework 👍 https://github.com/proyecto26/ion-phaser
Example:
import React, { Component } from 'react'
import Phaser from 'phaser'
import { IonPhaser } from '@ion-phaser/react'
class App extends Component {
state = {
initialize: false,
game: {
width: "100%",
height: "100%",
type: Phaser.AUTO,
scene: {}
}
}
render() {
const { initialize, game } = this.state
return (
<IonPhaser game={game} initialize={initialize} />
)
}
}
score:2
There is a module for this on Github called react-phaser. Here is a CodePen that does not use any separate module.
var PhaserContainer = React.createClass({
game: null,
...
componentDidMount: function(){
this.game = new Phaser.Game(800, 400, Phaser.AUTO, "phaser-container",
{
create: this.create,
update: this.update
});
},
...
render: function(){
return (
<div className="phaserContainer" id="phaser-container">
</div>
);
}
...
}
This is not my CodePen. Credit goes to Matthias.R
Source: stackoverflow.com
Related Query
- Using Phaser together with React
- Using state in react with TypeScript
- Testing React Functional Component with Hooks using Jest
- Using event.target with React components
- React with Typescript -- Generics while using React.forwardRef
- How to mock history.push with the new React Router Hooks using Jest
- Using google sign in button with react
- Using onBlur with JSX and React
- Can I avoid forceUpdate() when using React with Backbone?
- Using Jest to mock a React component with props
- Dealing with an empty array when using .map() in React
- How do I store JWT and send them with every request using react
- Using Dynamic Var with `Set` State in React Hooks?
- Prevent react component from rendering twice when using redux with componentWillMount
- Is there any way to see names of 'fields' in React multiple state with React DevTools when using 'useState' hooks
- Using compose() and connect() together in React JS redux
- Using React forwardRef with Typescript generic JSX arguments
- Proper way of using WebSockets with React Native
- Uncaught TypeError: create is not a function using useEffect React Hook with AJAX request
- Using Static HTML with React
- Using React Router with CDN and without webpack or browserify
- Using React forwardRef with Redux connect
- Using .less files with React
- Using Material Design Lite with React
- using mobx with react functional components and without decorators
- Error using component done with react,redux and react-redux and build with webpack in react application
- How can I serve robots.txt on an SPA using React with Firebase hosting?
- Error : Cannot read property fetch. Using jest-expo with react native
- react native post form data with object and file in it using axios
- How to use forwardRef with FunctionComponent in React Native using TypeScript
More Query from same tag
- Cookie from response doesn't get set in time for navigation within React component
- Fixed div responsive in css
- Why my InputBase focus doesn't work onClick React and Material UI
- Error in optional prop-types check in typescript
- Render dynamic list of react components from array of strings
- How to set default values on imported components in REACT
- Copy prototype functions from object in Redux reducer
- React Router -- Differentiate goBack() and goForward() in listen()
- Is there any way to check if constructor prop changed and then re-render component in React?
- What do color enum "inherit" and "default" mean in Material-UI?
- TypeError: null is not an object (evaluating 'variableRegex.exec(foundTranslation)[0]') replaceDynamicString
- How to use axios.all or promise.all to call all ajax calls just once? React
- How to pass parent value to child on first render and change parent component value from Child?
- Access to props in a React Js without render method
- if statement in the save props > return field?
- How can I Update Document in Collection firebase
- Fastify giving a react prop to a render with next.js
- React - Input loses focus when setState is called on a completely different component
- Ant design 4.0.1 - Access methods of child form inside class component from parent component
- What is causing my react page to be blank?
- How to re-render a heavy React component with a low priority?
- How to keep the image previews of images that I have already uploaded upon re-render of Uppy instance in a React app
- How to change method that pass couple value to field in state?
- How to transpile and minify single file with webpack?
- How to prevent component re-render (update) inside animations with REACT
- Slide effect is not working in react-owl-carousel after adding data dynamically to carousel
- Access Object Values with Context API in Child Component
- Conditional imports in React Native
- Calling render vs painting the DOM?
- External dependencies are incorrectly bundled in rollup.js?