car.js
function Car() {
return <h2>Hi, I am a Car!</h2>;
}
export default Car;
=
import React from 'react';
import ReactDOM from 'react-dom/client';
import Car from './Car.js';
const myelement = (
<table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>John</td>
</tr>
<tr>
<td>Elsa</td>
</tr>
</table>
);
const container = document.getElementById('sandy');
const root = ReactDOM.createRoot(container);
root.render(<Car />);
==
call funciton in another function
import React from 'react';
import ReactDOM from 'react-dom/client';
import Garage from './Garage.js';
const container = document.getElementById('sandy');
const root = ReactDOM.createRoot(container);
root.render(<Garage />);
=
function Car() {
return <h2>Hi, I am a Car!</h2>;
}
export default Car;
=
import Car from './Car.js';
function Garage() {
return (
<>
<h1>Who lives in my Garage?</h1>
<Car />
</>
);
}
export default Garage;
=
=
No comments:
Post a Comment