here my sandbox: https://stackblitz.com/edit/react-h1uaph
My console returns me
ref.current is null
but I cant understand since I pass the ref in the function arguments. I have read I cant access ref from the render function, maybe by analogy it is the same for the returns function -here in a functional component? BUt if it is the case how can I access to the ref from a functional component?
here my snippet:
import React from "react"
import ReactDOM from "react-dom"
const accessRef=(elementRef)=>{
if(elementRef && !elementRef.current) console.log("elementRef.current is null")
}
function App() {
let child1=React.createRef();
return(
<div
ref={child1}
name="child1"
className="circle_container pic2"
style={accessRef(child1)}
> hello world
</div>
)
}
ReactDOM.render(<App/>, document.getElementById("root"))
any hint would be great, thanks