diff --git a/README.md b/README.md index 42401ae6..f83aa74b 100644 --- a/README.md +++ b/README.md @@ -9724,6 +9724,18 @@ Technically it is possible to write nested function components but it is not sug ); ``` + #### Functional component version + ```javascript + const Greeting = ({ message }) => { + return
Hello {message}
; + }; + + ReactDOM.render( + , + document.getElementById("root") + ); + ``` + You can write the same code without JSX as below, ```javascript @@ -9739,6 +9751,18 @@ Technically it is possible to write nested function components but it is not sug ); ``` + #### Functional component version + ```javascript + const Greeting = ({ message }) => { + return React.createElement("div", null, `Hello ${message}`); + }; + + ReactDOM.render( + React.createElement(Greeting, { message: "World" }, null), + document.getElementById("root") + ); + ``` + **[⬆ Back to Top](#table-of-contents)** 84. ### How do you create HOC using render props?