简体   繁体   中英

React/Node - Include js component in another file

I have a component in a .js file which I have exported as default. I am trying to include this component in another .js file. I have also imported this component in the other file. I have tried using <componentName /> but this does not seem to work, it compiles and shows no error but nothing shows up. Any ideas?

First of all, as you are saying you are using it like <componentName /> , this won't work, you should try renaming it with all caps ie. <ComponentName /> . This is just an assumption. If the issue persists, please share the code, so that we can help you in a better way. Discussion can be found here .

如评论中所述,我尝试添加的组件名称必须以大写字母开头,因为将以小写字母开头的组件作为默认DOM元素进行搜索

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