简体   繁体   English

如何将这个javascript类转换为react可以使用的东西?

[英]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. 该文件夹位于我要在服务器和客户端上使用的名为shared的文件夹中,现在它在服务器上可以正常工作,但是我似乎无法弄清楚如何转换整个共享文件夹,因此我也可以在客户端。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何确认JavaScript中的内容然后使用 - How can I confirm something in JavaScript and then use 我如何使用主动伪 class 来显示一些东西 - how can i use active pseudo class to show something 如何使用 JavaScript 删除 class - How can I use JavaScript to delete a class 如何将使用“文化”数字格式的输入字符串转换为JavaScript可以理解的内容? - How can I convert an input string that uses 'cultural' number formatting into something JavaScript can understand? 我如何将这个常规的JavaScript函数转换为React.js可以读取的内容 - How can I turn this regular JavaScript function into something React.js can read 如何在iPad的safari上调试javascript和CSS(我可以在iPad上使用firebug之类的东西)吗? - How can I debug javascript and css on safari for iPad (Can I use something like firebug on iPad)? 如何在JavaScript中移动内容? - How can I make something move in javascript? 什么时候可以在react / react中使用reactDOM /如何使某些东西出现在屏幕上而不是在consoke中? - When can you use reactDOM in react/how can i make something appear on screen rather than in consoke? 如何在本机反应中将无状态 function 转换为 class 组件 - How can I convert stateless function to class component in react native 如何将 React.createclass 转换为 Class 组件? - How Can I convert React.createclass to Class Component?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM