when embedding this single scene phaser game into React page, the scene was duplicated into two. And every time updating the code, 2 more duplications are added on the page.
Game componenet as below:
import MainScene from './scenes/MainScene.js';
import Phaser from 'phaser';
import React, { Component } from 'react'
class Game extends Component {
componentDidMount(){
const config = {
width: 640,
height: 1024,
backgroundColor: '#333333',
type: Phaser.AUTO,
parent: 'phaser-game',
scene: [MainScene]
};
new Phaser.Game(config);
}
shouldComponentUpdate() {
return false;
}
render() {
return <div id="game" />
}
}
export default Game;
here can see two canvas elements are created

thanks in advance!