question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SearchBar Typescript types are broken

See original GitHub issue

Explain what you did (Required)

I’m using SearchBar in typescript. I have a state variable to store the search text:

  const [search, setSearch] = React.useState<string>();
  return (
      <SearchBar
          onChangeText={setSearch}
        />
  )

Expected behavior (Required)

I expect this to be a valid usage according to Typescript.

Describe the bug (Required)

TS says onChangeText doesn’t match, but the required property type is essentially disjoint (I think).

index.tsx(74,11): error TS2322: Type '(text: string) => void' is not assignable to type '((text: string) => void) & ((text: string) => void) & (() => any) & (() => any) & (() => any) & ((text: string) => void) & (() => any) & (() => any) & (() => any)'.
  Type '(text: string) => void' is not assignable to type '() => any'.

Your Environment (Required):

software version
react-native-elements 3.4.2
react-native 0.64.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:10
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
haythamhakimcommented, Aug 20, 2021

Any updates on this?

6reactions
harshal-moneylioncommented, Jul 31, 2021

What is the release plan for the same? been 25 days since the last activity here. And no new release has been done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript error when using SearchBar from react-native ...
According to this issue, the type definition is broken in the latest version. Until the new version come out, you can do the...
Read more >
SearchBar typescript props missing · Issue #2878 - GitHub
I get a typescript error on: searchFieldRef.current?.blur(); - it doesn't know about blur. ref={searchFieldRef} on the SearchField itself.
Read more >
Search Bar in React featuring Typescript and Redux | by Roza J
Have been using Typescript and Redux lately and thought it would be a ... 4: Break List into its own component; Step 5:...
Read more >
Example of Search Bar in React Native - Snack
Searching using Search Bar Filter in React Native List View // https://aboutreact.com/react-native-search-bar-filter-on-listview/ // import React in our ...
Read more >
How to Filter and Search using Variables in Apollo Client
This last step is broken into two parts. First, we update the query to use a query variable called albumsInput to refer to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found