From 7f4ed67e44f02e1ad5b52f9bc96f2bbe89dd07aa Mon Sep 17 00:00:00 2001 From: Anukiran Ghosh <59087982+akghosh111@users.noreply.github.com> Date: Sat, 28 Jun 2025 19:31:32 +0530 Subject: [PATCH] Update class-based component to functional component Issue - https://github.com/sudheerj/reactjs-interview-questions/issues/359 Updated Question no. 83(https://github.com/sudheerj/reactjs-interview-questions?tab=readme-ov-file#is-it-possible-to-use-react-without-jsx) solution, class based to functional --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 382f064d..e58dda85 100644 --- a/README.md +++ b/README.md @@ -9724,10 +9724,8 @@ Technically it is possible to write nested function components but it is not sug For example, let us take a greeting example with JSX, ```javascript - class Greeting extends React.Component { - render() { - return
Hello {this.props.message}
; - } + function Greeting(props) { + return
Hello {props.message}
; } ReactDOM.render( @@ -9739,16 +9737,15 @@ Technically it is possible to write nested function components but it is not sug You can write the same code without JSX as below, ```javascript - class Greeting extends React.Component { - render() { - return React.createElement("div", null, `Hello ${this.props.message}`); - } + function Greeting(props) { + return React.createElement("div", null, `Hello ${props.message}`); } ReactDOM.render( React.createElement(Greeting, { message: "World" }, null), document.getElementById("root") ); + ``` **[⬆ Back to Top](#table-of-contents)**