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!

React

!react@programming.dev

Create post

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

https://react.dev/

Wormhole

!pico8@programming.dev

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

Community stats

  • 20

    Monthly active users

  • 48

    Posts

  • 23

    Comments