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.

React Native with Typescript - void has no call signature

See original GitHub issue

🐛 Bug report

Current Behavior

I cannot chain the handleChange function and call it again because the types say that it may return void, this is also giving me that error when trying to put that function in my input’s onChangeText method image

Expected behavior

handleChange is always returning a function so it shouldn’t have void in its return types

Reproducible example

I got this error while using the useFormik hook with React Native and using the handleChange method provided by the useFormik hook

Your environment

Software Version(s)
Formik 2.0.1-rc.13
React 16.9.0
React Native 0.60.5
TypeScript 3.6.3
Browser Chrome
npm/Yarn Yarn 1.17.3
Operating System Mac OS

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:15
  • Comments:5

github_iconTop GitHub Comments

3reactions
pybuchecommented, Apr 1, 2020

Up ! Is there any news on this ?

3reactions
mbaroukhcommented, Feb 29, 2020

the workaround suggested by @PawelJ-PL works and you can use it to make your own useFormik hook like this:

import { useFormik, FormikConfig } from "formik"

export default <V>(config: FormikConfig<V>) => {
  const value = useFormik(config)

  type UsableType = {
    handleChange: (name: string) => (text: string) => void
    handleBlur: (name: string) => (event: any) => void
  } & typeof value

  return value as UsableType
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript react context + Type '{}' has no call signatures
Error This expression is not callable. Type '{}' has no call signatures. Toast Hook <button onClick={() => { return ...
Read more >
this expression is not callable. type 'never' has no call ...
React component in TypeScript if passed as parameter and assigned to variable; TS2604: JSX element type does not have any construct or call...
Read more >
TypeScript Error "element type does not have any construct or ...
Hello all, I am new to react and typescript and I am getting an error ... TypeScript Error "element type does not have...
Read more >
typescript-cheatsheet - GitHub Pages
If no types are declared, TypeScript will automatically assign a type depending on ... A great comparison and example for abstract classes is...
Read more >
This expression is not callable. Type 'Thunk<Collections ...
Type 'Thunk<Collections, undefined, any, {}, any>' has no call signatures · Nested map in Typescript and React return error this expression is not...
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