Build simple react components that implement a render () method, which takes input data and returns data to display. Use as XML-like syntax called JSX. Input data, passed into the component can be accessed by render () via this.props
![]() |
| Creating a React Component with XML Syntax Passing Input by props | Indiantechonera |
Hello.js
function Hello (props) {
return (
<h1>
Hello {props.fname} {props.lname}
</h1>
)
}
export default Hello
index.js
import React from 'react'
import ReactDOM from 'react-dom/client'
import Hello from './Hello'
const root = ReactDOM.createRoot(document.getElementById('root'))
root.render(
<>
<Hello fname='Sam' lname='Edward' />
</>
)
.png)