I'm new to nodejs + react and I guess this is a basic react syntax. I'm just not used to it coming from another language. I want to confirm if I'm right:
I am trying an open react project which is successfully deployed and works for sure.
In the entry file, index.js
:
...some code...
import AdminLayout from "layouts/Admin/Admin.js";
...some code...
ReactDOM.render(
<ThemeContextWrapper>
<BackgroundColorWrapper>
<BrowserRouter>
<Switch>
<Route path="/admin" render={(props) => <AdminLayout {...props} />} />
<Route path="/rtl" render={(props) => <RTLLayout {...props} />} />
<Redirect from="/" to="/admin/dashboard" />
</Switch>
</BrowserRouter>
</BackgroundColorWrapper>
</ThemeContextWrapper>,
document.getElementById("root")
For the component AdminLayout
, it is imported from layouts/Admin/Admin.js
. However, I checked the file and there is no variable named AdminLayout
at all, layouts/Admin/Admin.js
is as follows:
...some code...
function Admin(props) {
...some code...
}
export default Admin;
There is just the Admin
being exported.
So, is it true that in react, you can import a component with a different name?
I did some search but cannot any description on this small detail.