I want to create an event for my button that is in in my AsideMenu component that take the current width and if it's equal to 5vw than it will make it to 10vw else it will put it at 5vw and it must overlap the div named home. This is the code:
Thank you
I know how to do it with it vanilla javascript but not in react
import React from 'react'
import AsideMenu from '../components/AsideMenu'
import './Home.css'
const Home = (props) => {
return (
<div className='assemble'>
<div >
<AsideMenu />
</div>
<div className='home'>
<h1>Home</h1>
</div>
</div>
)
}
export default Home```
CodePudding user response:
You can use a useRef and get the current width. This video will explain it better for you.{https://youtu.be/t2ypzz6gJm0}...In case you get stuck, feel free to reach out. After using the useRef , you can then use a tenary statement in the return statement to actualize the code