HomeToolsAbout

Elements

Alternative Elements to div

// Alternative HTML tags to <div> <section/> <article/> <main/> <aside/> // empty element in JSX <></>

Referencing HTML element

Chaining useRef and useEffect together, you can reference the element.

import {useEffect, useRef} from "react"; function Foo() { const inputEl = useRef(null); useEffect(() => { // do something with `inputEl` here }, []); return <Bar ref={inputEl} /> }

properties vs attributes

Attributes

<input type="text" value="Hello" />

Properties

const input = document.querySelector("input"); input.value = "Goodbye"; // value property
AboutContact