Skip to content

TypeError: Object(...) is not a function #127

@KimWooHyun

Description

@KimWooHyun

Hi!

I installed the package use-query-params: 1.1.7
but I'm getting this error When I used setQuery In react with ts, any sugestion?

image

App.tsx

import { BrowserRouter, Route } from 'react-router-dom';
import { QueryParamProvider } from 'use-query-params';

const App = (): React.ReactElement => {
  return (
    <BrowserRouter>
      <QueryParamProvider ReactRouterRoute={Route}>
        ...
      </QueryParamProvider>
    </BrowserRouter>
  );
})

index.tsx

import { useQueryParams, StringParam } from 'use-query-params';

const Test = (): React.ReactElement => {
  const [query, setQuery] = useQueryParams({
    foo: StringParam,
  });
  const { foo } = query;

  return (
    <button onClick={() => setQuery({ foo: 'test!' })}>Test</button>
  )
};

I used

"use-query-params": "1.1.7",
"query-string": "6.13.2",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions