Get the height of an element and show/hide More… button depending on the element's height

Advertisements I’m new to React and NextJs. I want to get the height of an element and depending on its height, to show or not to show the More… button. What I’ve tried is this: import {useRef, useState} from "react"; const MyText = (props) => { const [myState, setMyState] = useState(null) const setContent = (e)… Read More Get the height of an element and show/hide More… button depending on the element's height

How to get children div via parent useRef in Reactjs

Advertisements I have div like that const indexRef = useRef(); <div className=’indexBx’ ref={indexRef}> <span className=’active’>01</span> <span className=’active’>02</span> <span className=’active’>03</span> </div> So now I want to change the secondary span classname via indexRef like something indexRef.current.span:nth(2).className = ??? How can I do that >Solution : // change class of second child indexRef.current.children[1].className = ‘passive’

Why does the React hook useRef throw an error when used?

Advertisements The error This is the error that shows in the brower over the webpage. Compiled with problems:X ERROR src\components\SignIn.js Line 5:21: React Hook "useRef" is called in function "signin" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names… Read More Why does the React hook useRef throw an error when used?