Toggle handleSelect is triggered upon rendering
See original GitHub issueI 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:
- Created a year ago
- Comments:7 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
perfect, thanks for using our library and being so involved 😃
Working great now @mitrotasios! Great job, super fast