Hey so I'm actually having some trouble getting this to work in my actual setup. It works well when I just toggle it with a button, but has some issues with how I did it.
This is in my app.tsx component
const [ useLeftAnchor, setUseLeftAnchor ] = useState(false)
...
useEffect(() => {
console.log(`useEffect ${useLeftAnchor}`)
}, [useLeftAnchor])
...
<Box sx={{
position: 'absolute',
bottom: 40,
...(useLeftAnchor ? { left: 40 } : { right: 40 }),
transform: `scale(${scale})`,
opacity: `${opacity}%`,
transition: 'opacity 0.25s ease'
}}>
</Box>
...
<Menu useLeftAnchor={useLeftAnchor} setUseLeftAnchor={setUseLeftAnchor}/>
I have this in the menu component, and I passed the useState as props.
<SegmentedControl sx={{float: 'right'}}
value={useLeftAnchor}
onChange={setUseLeftAnchor}
data={[
{label: 'Right', value: 'false'},
{label: 'Left', value: 'true'}
]
}/>