Skip to content

Instantly share code, notes, and snippets.

@sudogem
Last active September 13, 2017 02:42
Show Gist options
  • Save sudogem/4424ef1997deb3f502d7f251d7a4a777 to your computer and use it in GitHub Desktop.
Save sudogem/4424ef1997deb3f502d7f251d7a4a777 to your computer and use it in GitHub Desktop.
hings to remember in ReactJS
const greeting = <h1>hello world!</h1>
// If you have JSX code that spans across multiple lines,
// you can wrap it in ( and ) brackets, as follows:
const greeting = (
<h1>
hello world!
</h1>
)
// =================================================================
// ReactDOM escapes all values embedded in JSX before rendering.
// This means that it is totally safe to embed user input via JSX.
const name = 'dan'
const greeting = (
<h1>
hello {name}!
</h1>
)
// =================================================================
// In JSX, all JavaScript expressions are valid when written in curly brackets { }.
// They will be evaluated, and the result will be inserted in place of the expression.
// Example:
const name = 'dan'
const greeting = (
<h1>
hello {name.toUpperCase()}!
</h1>
)
// =================================================================
// Functional components
// It is best practice to name React components starting with an uppercase letter,
// to be able to distinguish them from simple HTML elements when they are used in JSX.
const Greeting = ({ name }) => (
<h1>
hello {name}!
</h1>
)
References:
https://www.safaribooksonline.com/library/view/learning-redux/9781786462398/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment