Renaming methods of imports?

Asked

Viewed 66 times

-1

First I’d like to know if I can call elements that we import of methods, that is to say:

import { Icon, Button, cabecalho : Header} from 'semantic-ui-react'

Could I call Icon, Button or Header methods? After this question I would like to know if it is possible to rename this "method" as for example this header to one of my preference. I am having a problem with this and I would like to know if it is possible or if there is some way to make it have two "things" with the same name but that do different things.

[![insert image description here][1][1]

  • Please, edit your question to remove the image code. As you can read here, code as image is not a good practice on this site.

1 answer

5

How are you using the imports specified by Ecmascript 2015, you can rename them using notation as, thus:

import { Foo } from 'foo-module';

typeof Foo; // "function", por exemplo.

To:

import { Foo as CustomName } from 'foo-module';
// `CustomName` é agora um *alias* para `Foo` (que deixa de estar no escopo).

typeof Foo; // "undefined"
typeof CustomName; // "function", por exemplo.

To learn more, be sure to consult documentation.


Regarding nomenclature, only being part of an import is not possible to classify them as methods, since Ecmascript defines that any value can be exported by a module X.

In this case, however, it is possible to state that they are "React components" (which is not a name standardized by Ecmascript, but which allows us to conclude that it is a class or function).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.