Skip to content

Typescript errors when using useHydrateAtoms #2262

Answered by dai-shi
ioExpander asked this question in Bug report
Discussion options

You must be logged in to vote

I looked into this, but we don't have an ultimate solution, because TS can't extract types from overloaded function. Just considered about exporting an untyped util, but that's not nice. As a Map is untyped, my recommendation is the following:

https://tsplay.dev/WvQ0Qm

import { Provider, atom, useAtomValue, type WritableAtom } from "jotai";
import { useHydrateAtoms } from "jotai/utils";
import { type ReactNode } from "react";

const testAtom = atom("");

export default function JotaiTests() {
  return (
    <Provider>
      <AtomsHydrator atomValues={[[testAtom, "hello"]]}>
        <MyComponent />
      </AtomsHydrator>
    </Provider>
  );
}

//This component contains all the states and …

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
9 replies
@dai-shi
Comment options

@ioExpander
Comment options

@dai-shi
Comment options

Answer selected by ioExpander
@ioExpander
Comment options

@dai-shi
Comment options

@ioExpander
Comment options

@rainagalbiati-turngate
Comment options

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