How to use the react-query.useQueryCache function in react-query

To help you get started, we’ve selected a few react-query examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gempir / justlog / web / src / components / Filters.tsx View on Github external
export function Filters() {
    const { setCurrents, state } = useContext(store);
    const queryCache = useQueryCache();
    const channels = useChannels();

    const handleSubmit = (e: FormEvent) => {
        e.preventDefault();

        if (e.target instanceof HTMLFormElement) {
            const data = new FormData(e.target);

            const channel = data.get("channel") as string | null;
            const username = data.get("username") as string | null;

            queryCache.invalidateQueries(["log", { channel: channel?.toLowerCase(), username: username?.toLowerCase() }]);

            setCurrents(channel, username);
        }
    };