简体   繁体   中英

How can I convert this javascript class to something react can use?

const Component = require('../Component')

class PlayerComponent extends Component {
    constructor(uid, username){
        super('PlayerComponent');
        this.username = username;
        this.uid = uid;
    }
}

module.exports = PlayerComponent;

This is in a folder called shared that I want to use on the server and the client, right now it's working fine on the server but I can't seem to figure out how to transpile the whole shared folder so I can also use it on the client.

您应该从客户端的React.Component继承。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM