kadirahq / mantra

Mantra - An Application Architecture for Meteor
https://kadirahq.github.io/mantra/
978 stars 52 forks source link

Higher-order Components in Mantra #177

Closed payner35 closed 8 years ago

payner35 commented 8 years ago

Probably not a direct Mantra question but...

Im trying to set up a simple HOC.

import React from 'react';

var CoreItem = Component => class extends React.component {
    constructor(props){
        super(props);
        this.doSomething = this.doSomething.bind(this);
    }

    doSomeThing(){
        console.log("doing something");
    }

    render(){
        return (
            <Component
                doSomething = {this.doSomething}
                {... this.state}
                {... this.props}>
            </Component>
        );
    }
};

export default CoreItem;

and then call it like so...

import React from 'react';

import CoreItem from '/client/modules/cms/components/coreItem.jsx';

class EventAdmin extends React.Component {

      render(){

        return(
            <div>
              <p>some text</p>
            </div>
        );
      }
}

export default CoreItem(EventAdmin);

i'm getting an error.

Super expression must either be null or a function, not undefined

payner35 commented 8 years ago

my bad....

class extends React.component vs class extends React.Component