Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle does not work with statepathtree #22

Open
RikScheffer opened this issue Jun 11, 2021 · 0 comments
Open

Toggle does not work with statepathtree #22

RikScheffer opened this issue Jun 11, 2021 · 0 comments

Comments

@RikScheffer
Copy link

RikScheffer commented Jun 11, 2021

with this state setup

import { createReducer, createStatePaths } from 'redux-updaters';

export type AppState = {
	menuOpen: boolean;
};

const defaultState: AppState = {
	menuOpen: false,
};

export const app = createStatePaths(defaultState);

export const appReducer = createReducer<AppState>(defaultState, 'app');

I am able to use for example:

import { app } from '_redux/app';
...
dispatch(update(app.menuOpen, true));

however if I try this:

import { app } from '_redux/app';
...
dispatch(toggle(app.menuOpen));

I get the error Toggle: menuOpen is not a boolean
However, when I try

dispatch(toggle('app.menuOpen'));

it does work

so it seems the typecheck is unable to handle state trees

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant