Can you use es6 import alias syntax for React Components?

前端 未结 6 1907
抹茶落季
抹茶落季 2021-01-30 12:35

I\'m trying to do something like the following, however it returns null:

import { Button as styledButton } from \'component-library\'

then atte

6条回答
  •  礼貌的吻别
    2021-01-30 13:21

    Careful with capitalisation. Best to always CamelCase.

    One:

    import Thing from "component";
    

    One with alias:

    import {Thing as OtherThing} from "component";
    

    One with alias plus other defaults:

    import {Thing as OtherThing}, Stuff, Fluff from "component";
    

    More detailed example

    import
    {Thing as StyledButton},
    {Stuff as Stuffing},
    {Fluff as Fluffy},
    Wool,
    Cotton
    from "component";
    

提交回复
热议问题