Quick and easy React snippets that you're always looking for but never find
component
React components implement a render() method that takes input data and returns what to display. This example uses an XML-like syntax called JSX. Input data that is passed into the component can be accessed by render() via this.props.
fetch
Doing a (GET) fetch request on component mount
This is a simple react function component
event-handling
a button example in React for a specific onClick event handler
Use JavaScript operators like if or the conditional operator to create elements representing the current state
Render multiple react components without the need of a DOM elevent wrapper
hooks
Returns a stateful value, and a function to update it
useEffect hooks lets perform an action whenever a value changes
A simple form in React using useState hooks
dangerouslySetInnerHTML is React’s replacement for using innerHTML in the browser DOM.