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.

"Invalid hook call" occurred when add kotlin-styled to dependencies

See original GitHub issue

I wrote functional component using hooks like this

val component = functionalComponent<RProps> {
    val (inputText, setText) = useState("")
    textArea {
        attrs.onChangeFunction = {
            val target = it.target as HTMLTextAreaElement
            setText.invoke(target.value)
        }
    }
    div {
        + inputText
    }
}

This code works, but when I add kotlin-styled dependency, this code crashed.

Here is a sample code. You can check by comment-out kotlin-styled dependency and running ./gradlew browserRun. https://github.com/yt8492/kotlin-react-hooks-sample

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
yt8492commented, May 4, 2020

@turansky I confirmed this problem resolved. Thank you!

1reaction
yt8492commented, Apr 30, 2020

I see. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid Hook Call Warning - React
You can only call Hooks while React is rendering a function component: ... incorrectly specifies react as a dependency (rather than a peer...
Read more >
React hooks in react library giving Invalid hook call error
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the...
Read more >
Solving React Hooks' invalid hook call warning - Rob Kendal
How to fix the invalid hook call warning. In a normal setup, you'll have a dependency pushed to some hosting repository, such as...
Read more >
Error: Invalid hook call - Material Design for Bootstrap
Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1....
Read more >
Invalid hook call - How to resolve multiple versions of React ...
react.development.js:209 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen ...
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