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.

10.0.0-alpha.0 - Hook useEffect never gets called

See original GitHub issue

When using a code like this in 10.0.0-alpha.0:

import { useEffect } from 'preact/hooks';

function Component(props) {
    useEffect(() => {
        console.log('effect');
    });

    return <div> test </div>;
}

The console log never gets called. I’m having a hard time getting preact functional components to work in codesandbox or I’d have posted a repro, sorry about that.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
marvinhagemeistercommented, Mar 7, 2019

Can confirm, just tried it out with the code in master and the issue is fixed there 🎉

3reactions
andrewigginscommented, Mar 7, 2019

I think this might be fixed in master. I was seeing similar behavior and submitted #1320 to fix my issue. Hopefully it fixes this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useEffect not being called and not updating state when api is ...
I'm fetching data from a weather api using useEffect hook and declaring the dependency correctly as well. My state ...
Read more >
Preact on Twitter: "⚛️ Preact X is now in alpha!! Fragments ...
Wow, this is awesome! I believe that useEffect is broken though, it never gets called where as the same code runs fine in...
Read more >
react-i18next | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Hooks API Reference - React
Hooks are a new addition in React 16.8. They let you use state and other React features without writing a class. This page...
Read more >
Get Hooked on React! | Object Computing, Inc.
Get Hooked on React! ... Hooks are a feature added in React 16.7.0-alpha.0. ... An effect is configured by calling the useEffect function,...
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