Skip to content

Instantly share code, notes, and snippets.

@jacobdo2
Created November 27, 2021 10:59
Show Gist options
  • Save jacobdo2/8c46c7a0f74d72c854284a9b815bc398 to your computer and use it in GitHub Desktop.
Save jacobdo2/8c46c7a0f74d72c854284a9b815bc398 to your computer and use it in GitHub Desktop.
export default function Parent() {
const [items, setItems] = useState([]);
const firstNewItemIndex = useRef();
const handleSetItems = () => {
setItems((prevItems) => {
firstNewItemIndex.current = prevItems.length + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment