Answer the question
In order to leave comments, you need to log in
Am I importing a component in React correctly?
I am learning React.
Working code.
An example of a component that I will be importing.
MyComponent.jsx
import React from 'react';
const MyComponent = () =>
{
return (
<div className="MyComponent">
Содержимое компоненты, JSX код и т. д.
</div>
);
}
export default MyComponent;
import React from 'react';
import Header from './components/MyComponent';
const App = () => {
return (
<div className="App">
<div className="wrapper">
<MyComponent />
</div>
</div>
);
export default App;
Answer the question
In order to leave comments, you need to log in
1) Not enough. The component itself requires self-sufficiency in the use of other components in it.
2) It is possible in js as well. But in this case, templates will have to be built through cumbersome functions. jsx is an extension that allows you to build a component template in much the same way as writing regular html
3) Yes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question