this post was submitted on 28 Jun 2023
3 points (100.0% liked)

React

939 readers
1 users here now

A community for discussing anything related to the React UI framework and it's ecosystem.

https://react.dev/

Wormhole

[email protected]

Icon base by Skoll under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

RTK Query Loader lets you create loaders for your React components.

const loader = createLoader({
  useQueries: () => {
    const [name, setName] = useState("charizard");
    const debouncedName = useDebounce(name, 200);
    const pokemon = useGetPokemon(debouncedName);
    return {
      queries: {
        pokemon,
      },
      payload: {
        name,
        setName,
      },
    };
  },
});

const Consumer = withLoader((props, data) => {
  return (
    <div>
      <input
        value={data.payload.name}
        onChange={(e) => data.payload.setName(e.target.value)}
      />
      <div>AP: {data.queries.pokemon.data.ability_power}</div>
    </div>
  );
}, loader);
no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here