trueadm / t7

Lightweight virtual DOM templating library
900 stars 31 forks source link

"No `render` method found on the returned component instance" #22

Closed boxxxie closed 8 years ago

boxxxie commented 8 years ago

using react, in plnkr.co, without jsx support.

was able to get your react complex component example working, when i try to get your non react example i (the MyWidget one on the readme) i get errors.

Warning: MyWidget(...): Norendermethod found on the returned component instance: you may have forgotten to definerenderin your component or you may have accidentally tried to render an element whose type is a function that isn't a React component.

Warning: Don't set the props property of the React element. Instead, specify the correct value when initially creating the element.

MyWidget ReactElement 
{
type: "div", 
key: null, 
ref: null, 
_owner: null, 
_context: Object,
_store: Object
}

code

t7.module(function(t7) {

  t7.setOutput(t7.Outputs.React);

  function MyWidget(props) {
    return t7`
      <div>
        <span>I'm a widget ${ props.welcome }</span>
      </div>
    `;
  }

  console.log("MyWidget", MyWidget({welcome : "123"}));

  t7.assign("Widget", MyWidget);

  React.render(
     t7`
        <div>
          <header>
            <Widget welcome="Hello world" />
          </header>
        </div>
      `,
    document.getElementById('example')
  );

});

when i change MyWidget to be

  const MyWidget = React.createClass({
    render: function () {
      return t7`
        <div>
          <span>I'm a widget ${ this.props.welcome }</span>
        </div>
      `;
    }
  });

things work.

i'm not sure if this is a bug, or the documentation needs to be updated, or if i am doing something wrong.

trueadm commented 8 years ago

@boxxxie I've just tried this and it works for me. I'll push the example in the examples folder so you can see. :) I hope that helps?