Component Rules
- Must start with capital letter. (Line number 5 , Arrow func component)
- Must always return JSX(html)
- Dont forget to close the tag (Line number 12 , Arrow func component)
- <App/>Â
1. Function Component
function App() {
return Welcome to react js!!
;
}
export default App;
2. Arrow Function Component
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
const App = () => {
return Arrow function !!;
};
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
);
3. Class Component
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
class App extends React.Component {
render() {
return This is class component !!
;
}
}
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
);