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

add update type #53

Merged
merged 1 commit into from
Jul 16, 2020
Merged

add update type #53

merged 1 commit into from
Jul 16, 2020

Conversation

hoilzz
Copy link
Contributor

@hoilzz hoilzz commented Apr 12, 2020

To specify SetCountContextType, it is written as immerHook<S>[1].

So, I suggest Update type.

const CountContext = React.createContext(0);

type SetCountContextType = ImmerHook<number>[1];
// type SetCountContextType = Update<number>;

const SetCountContext = React.createContext<SetCountContextType>(
  {} as SetCountContextType
);

export default function App() {
  const [count, produceCount] = useImmer(0);

  return (
    <CountContext.Provider value={count}>
      <SetCountContext.Provider value={produceCount}>
		{...}
      </SetCountContext.Provider>
    </CountContext.Provider>
  );
}

@hoilzz hoilzz marked this pull request as ready for review April 12, 2020 06:19
@deluksic
Copy link

deluksic commented Apr 30, 2020

Do you think it makes sense to call this Produce<> instead of Update<> ?

@mweststrate
Copy link
Collaborator

Looking fine, thanks!

@mweststrate mweststrate merged commit 700b942 into immerjs:master Jul 16, 2020
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

Successfully merging this pull request may close these issues.

3 participants