Open amitshahc opened 4 years ago
This example shows React without JSX. Adding JSX to a project doesn’t require complicated tools like a bundler or a development server. Essentially, adding JSX feels a lot like adding a CSS preprocessor. These two code snippets are equivalent. While JSX is completely optional, many people find it helpful for writing UI code — both with React and with other libraries. You can play with JSX using this online converter
The same result if you write some code like this, just without state
:
React.createElement('button', { onClick: () => alert('The button was clicked') }, 'Click me')
When I was trying to follow this documentation: https://reactjs.org/docs/add-react-to-a-website.html#optional-try-react-with-jsx all worked fine until I replaced native
JavaScript
toJSX
.The missing step is to replace the line:
ReactDOM.render(e(LikeButton), domContainer);
withReactDOM.render(<LikeButton />, domContainer);