I have a svg component that is declared like so:
import {ReactComponent as Icon} from 'someplace.svg'
function SomeComponent(props){
const [someState, setSomeState] = useState(0)
const iconRef = useRef(null)
useEffect(() => {
//always prints null
console.log(iconRef.current)
}, [someState])
return <div>
<button onClick={() => setSomeState(prev => prev + 1)}>{someState}</button>
<Icon ref={iconRef}/>
</div>
}
The problem here is that iconRef will always return null. I think this is because it is declared as a component so the ref would need to be forwarded directly to the svg tags but how do I do that?
Any ideas?