Skip to content

Instantly share code, notes, and snippets.

@amirulabu
Created February 23, 2019 09:29
Show Gist options
  • Save amirulabu/978516d69c6cfd2746f6f54ff03f2676 to your computer and use it in GitHub Desktop.
Save amirulabu/978516d69c6cfd2746f6f54ff03f2676 to your computer and use it in GitHub Desktop.
const props = {
className: 'container',
children: 'Hello World'
}
const element = <div className={props.className} children={props.children} />
const element1 = <div {...props}/>
const element2 = <div className="my-class" {...props}/>
const element3 = <div {...props} children="Hello Mirul" />
const element4 = <div {...props}>Hello Mirul</div>
const element5 = React.createElement('div', {
id: 'greeting',
className: 'active',
children: 'Hello ' + user.name,
})
const Message = (props)=> <div>{props.msg}</div>
const element6 = <Message msg='Hello World' />
const Message2 = (props) => <div>{props.children}</div>
const element7 = <Message2>Hello World</Message2>
const rootElement = document.getElementByID('root')
const element8 = (<div>This is a test</div>)
ReactDOM.render(element, rootElement)
@amirulabu
Copy link
Author

copy paste this at https://babeljs.io/repl to find out how JSX translate to JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment