How to use the use-query-params.withDefault function in use-query-params

To help you get started, we’ve selected a few use-query-params 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 clems4ever / go-graphkb / web / src / views / ExplorerView.tsx View on Github external
const ExplorerView = () => {
    const theme = useTheme();
    const styles = useStyles();
    const [sources, setSources] = useState(undefined as string[] | undefined);
    const [query, setQuery] = useState(QUERY);
    const [submittedQuery, setSubmittedQuery] = useQueryParam("q", withDefault(StringParam, QUERY));
    const [queryResult, setQueryResult] = useState(undefined as QueryResultSetWithSources | undefined);
    const [isQueryLoading, setIsQueryLoading] = useState(false);
    const [error, setError] = useState(undefined as undefined | Error);
    const [schemaOpen, setSchemaOpen] = useState(false);
    const [databaseDialogOpen, setDatabaseDialogOpen] = useState(false);
    const [searchValue, setSearchValue] = useState("");
    const [searchFocus, setSearchFocus] = useState(false);

    const handleQuerySubmit = useCallback(async (q: string) => {
        setSubmittedQuery(q);
    }, [setSubmittedQuery]);

    useEffect(() => {
        (async function() {
            setIsQueryLoading(true);
            try {