React Flashcards
React is used to…
create components, handle state and props, utilize event listeners and certain life cycle methods to update data as it changes
react combines
HTML with JS functionality to create its own markup JSX
nested JSX must return ____ element
a single
several JSX elements written as siblings with no parent wrapper element _____ transpile
will not transpile
commenting JSX
{/* */}
how to render React elements to the DOM
ReactDOM.render(componentToRender, targetNode)
ReactDOM.render(, document.getElementById(“challenge-node”));
define HTML classes in JSX
className instead of class
everything changes to camel case as well
rules around closing tags
any can be written with a self-closing tag & every element must be closed
everything in React is a
component
a stateless component is
one that can receive and render data, but doesn’t make or track changes to it
React requires your function name to begin with
a capital letter
syntax to create a stateless component
const name = function() { return ( ); };
two ways to define React components
- function
2. class
create a component by extending React.Component
class Kitten extends React.Component { constructor(props) { super(props); }
render() { return ( <h1>Hi</h1> ); } }
create component with composition
create parent component and write it as a tag in the return part of render()
return (
)