React.js: Is it possible to namespace child components while still using JSX to refer to them?

你说的曾经没有我的故事 提交于 2019-12-03 12:56:15

This pull request was just merged:

https://github.com/facebook/react/pull/760

It allows you to write things like <myComponents.ImageGridItem /> in React 0.11 and newer.

That said, a proper module system is the recommended way to manage dependencies to avoid pulling in code that you don't need.

Currently, there isn't a way to do this. Namespacing with JSX is on the todo list.

Most people use some kind of module system (browserify, webpack, requirejs), which replace namespacing and allow components to be used easily. There are a lot of other benefits, so I very much recommend looking into it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!