DEV Community

Discussion on: I have a problem with Vue composition API

Collapse
 
aissabouguern profile image
Aissa BOUGUERN • Edited

Thank you Alex,
Yes i now understand what's the problem,
I need to put some mechanism to share that state between those components. something like useContext in React.js

Collapse
 
alexanderjanke profile image
Alex Janke

Normally you can just move the state out of the function.
Something like

export const state = ref(false)
export const toggleMenu = () => {
  state.value = !state.value;
}

Not tested but this should work I think