Multiple React components in a single module

后端 未结 4 1938
悲&欢浪女
悲&欢浪女 2020-12-08 21:43

I am new to the whole browserify thing. I have been trying to use browserify + reactify + gulp to transform, minify and combine a React application. As long as I have a sing

4条回答
  •  無奈伤痛
    2020-12-08 22:13

    You can simply export multiple components as an array:

    module.exports = [Component1, Component2]
    

    Then to use the components:

    var MyComponents = require('your/path/to/components');
    var Component1 = MyComponents[0];
    var Component2 = MyComponents[1];
    

提交回复
热议问题