evilfer / react-phaser

Other
101 stars 16 forks source link

How to use components? #3

Closed pradeeproark closed 8 years ago

pradeeproark commented 8 years ago

Lets say we have a component like below

var circlecompo = React.createClass({
    componentWillMount: function() {
        console.log('mount c');  
    },
    render: function(){
      return (
          <circle fill={0xFFFF0B} fillAlpha={0.5}
                  x={470} y={200} diameter={200}/>
      );
    }
});

and a

var MyGame = React.createClass({
render: function() {
return(
<game>
<circlecompo/>
</game>)
});

This doesn't work. There are no errors but the circle is not rendered. What is missing?

evilfer commented 8 years ago

Two possible reasons:

pradeeproark commented 8 years ago

I omitted the width and height in the issue description by mistake.

It was actually because the component name should be capital cased.

Ex: https://gist.github.com/anonymous/2773f909e0e9d90fa1385faee21aad3d

Works.