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.

Change Hook Running On Init

See original GitHub issue

Hi guys, I have a weird issue the change hook is running on plugin initializing, here is the test i did:

// Initialization
let picker = new CP(element);

// change hook listener
picker.on('change', function(r, g, b, a) {
    // firing immediately 
    console.log(1);
});

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mgabi4488commented, Aug 9, 2021

Thanks, that’s exactly how i solved the issue.

0reactions
taufik-nurrohmancommented, Apr 13, 2022

It’s not logical that changed fires when the picker gets instantiated.

@evolross There’s a drag event that you can use to prevent this behaviour if you want 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Skip hook change (useEffect) on initialize - Stack Overflow
I am using hooks for the selected index. I realized that hooks works async. When a new value was selected the old value...
Read more >
Simplifying state initializers with React Hooks - LogRocket Blog
1. Configurable initial state ... On line 2, the initial state within the Hook is set. ... Instead of hardcoding the initial state,...
Read more >
Lifecycle hooks - Angular
Called immediately after ngOnChanges() on every change detection run, and immediately after ngOnInit() on the first run. ngAfterContentInit(), Respond after ...
Read more >
Rules of Hooks - React
Hooks are JavaScript functions, but you need to follow two rules when using ... Initialize the name state variable with 'Mary' useEffect(persistForm) //...
Read more >
Angular Lifecycle Hooks: ngOnChanges, ngOnInit, and more
The hook receives one optional parameter of type SimpleChanges . This value contains information on the changed input-bound properties.
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