Skip to content

Is there a way to use Set types as part of the state? #30

@azinod

Description

@azinod

It doesn't seem to work out of the box, is there a way to enable/use them?

Example:

// CREATING STATE AND ACTIONS
import useMethods from 'use-methods';

const initialState = {
  idList: new Set()
};

const methods = state => ({
  addId: id =>{state.idList.add(id)},
  removeId: id => {state.idList.delete(id)}
});

const [state, actions] = useMethods(methods, initialState);

// USAGE
actions.addId(123); //does update the state but does not trigger a re-render

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions