What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-10-30 01:43:13
react how to scroll to element
import React, { useRef } from 'react' const scrollToRef = (ref) => window.scrollTo(0, ref.current.offsetTop) // General scroll to element function const ScrollDemo = () => { const myRef = useRef(null) const executeScroll = () => scrol... Add solution -
Other 2021-10-20 07:32:03
Detect click outside React component
import React, { useRef, useEffect } from "react"; /** * Hook that alerts clicks outside of the passed ref */ function useOutsideAlerter(ref) { useEffect(() => { /** * Alert if clicked on outside of element */ ... Add solution -
Javascript 2021-10-19 20:44:05
useReducer example
/* A common use case is to access a child imperatively: */ function TextInputWithFocusButton() { const inputEl = useRef(null); const onButtonClick = () => { // `current` points to the mounted text input element inputEl.current.focus(); ... Add solution -
Javascript 2021-10-18 16:13:04
ribbon banner for react native
import React, {useEffect, useState, useRef} from 'react'; import { Text, View, Dimensions, Image, Animated, StyleSheet, } from 'react-native'; export default function BadgeRibbon(props) { return ( <View> <View sty... Add solution -
CSS 2021-10-18 13:46:07
get input value with useref
import React, { Component, useRef } from 'react' import { render } from 'react-dom' import InputField from './inputfield' import './style.css' function App () { const nameForm = useRef(null) const handleClickEvent = () => { const form = na... Add solution