Skip to content

Toggle state value using selector. #1000

Answered by david-trumid
Berkays asked this question in Q&A
Discussion options

You must be logged in to vote

not sure why you want it parameterless if you are only showing the span when it is open, think you want to pass false in that case right?. I think you want this though

const SidenavSelector = selector({
	key: 'uiStateSidenavToggle',
	get: ({ get }) => get(uiState).isSidenavOpen,
	set: ({ get, set }) => set(uiState, (currentState) => ({...currentState, isSidenavOpen: !currentState.isSidenavOpen}))
});

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Berkays
Comment options

@david-trumid
Comment options

@Berkays
Comment options

Answer selected by Berkays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants