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.

Toggle handleSelect is triggered upon rendering

See original GitHub issue

I noticed that the handleSelect in the Toggle component is triggered when the component is rendered. I’ve got the following Toggle inside a ReactModal and as soon as the modal is opened the handleSelect triggers, causing unwanted API requests. I’m not completely sure if I’m making a mistake somewhere so I’m wondering if more people have noticed this behaviour.

<Toggle defaultValue={"2"} color="emerald" handleSelect={(value) => postMood(value)}>
                    <ToggleItem value={"1"} text="Great"/>
                    <ToggleItem value={"2"} text="Okay"/>
                    <ToggleItem value={"3"} text="Bad"/>
</Toggle>

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mitrotasioscommented, Oct 25, 2022

perfect, thanks for using our library and being so involved 😃

1reaction
StefBrandscommented, Oct 25, 2022

hey @StefBrands, the issue should be fixed with the new release v1.0.12.

Working great now @mitrotasios! Great job, super fast

Read more comments on GitHub >

github_iconTop Results From Across the Web

OnChange event using React JS for drop down - Stack Overflow
The change event is triggered on the <select> element, not the <option> element. However, that's not the only problem.
Read more >
How to Capture the Value of Dropdown Lists with React ...
This guide will show you how to use React Bootstrap to build a dropdown list for your forms and capture their values on...
Read more >
Using React Portals to Render Children Outside the DOM ...
Let's break down the steps for creating this toggled Portal element to see how it all works. Step 1: Create the Portal element....
Read more >
How to Create a Toggle Button in React Using Conditional ...
Create a toggle button to show and hide data using the useState hook. ... There are a few ways to render something conditionally...
Read more >
ASP.NET Core Blazor performance best practices
Avoid unnecessary rendering of component subtrees · Virtualization · Create lightweight, optimized components · Don't trigger events too rapidly.
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