wix-incubator / react-templates

Light weight templates for react
https://wix.github.io/react-templates
MIT License
2.82k stars 207 forks source link

allow explicit named exports with <rt-export> and --name #188

Open nippur72 opened 8 years ago

nippur72 commented 8 years ago

Currently react-templates exports the generated function as a "whole" module object as the only option. It can't export as named member or as default. There is also inconsistency with the command line option --name that works only in the case of global and AMD, but not commonjs.

I propose to:

E.g.

<rt-export as="MyComponent">
<div rt-stateless>...</div>
import { MyComponent } from "./mycomponent";

Also:

<rt-export default>
<div rt-stateless>...</div>
import MyComponent from "./mycomponent";
steezeburger commented 7 years ago

This would be awesome. Right now it's wonky importing stateless components with es6 imports.

export * as PromoError from './PromoError/promoErrorModal.rt.js';
export PromoInfo from './PromoInfo/PromoInfoModal';
export * as PromoSuccess from './PromoSuccess/promoSuccessModal.rt.js';

Edit: The above ended up not even working for my use case as I am using Component.displayName or Component.name to render the proper component in my HOC.