Skip to content

IonButton onClick event called twice with React @ionic/react #17292

Closed

Description

@josepol

Bug Report

Ionic version:

[x] 4.x

Current behavior:
IonButton component onClick event is being called twice with Ionic 4 with React

Expected behavior:
IonButton component onClick event should be called once

Steps to reproduce:
Create a new proyect with create-react-app
Install @ionic/react and @ionic/core as it is explained in https://www.npmjs.com/package/@ionic/react
Call registerIonic() on index.js
Import IonButton with import { IonButton } from '@ionic/react';
Declare IonButton component and add it the onClick event

Test it with console.log()

class App extends Component {

  incrementCount(e) {
    console.log('+++');
}

  decrementCount(e) {
    console.log('---');
  }

  render() {
    return (
      <div className="App">
        {/* This is called twice */}
        <IonButton onClick={(e) => this.incrementCount(e)}>Ionic Button +</IonButton>
        <IonButton onClick={(e) => this.decrementCount(e)}>Ionic Button -</IonButton>
        {/* This is called once */}
        <button  onClick={(e) => this.incrementCount(e)}>+</button>
        <button  onClick={(e) => this.decrementCount(e)}>-</button>
      </div>
    );
  }
}

export default App;

Am I doing something wrong? I have tested it in Chrome and Firefox

Thank you very much for your support!!

Activity

  1. silentHoo commented on Jan 28, 2019

    @silentHoo

    I've exactly found the same problem with my code and wanted to open an issue, too. The code to reproduce would be the same.

  2. manucorporat commented on Jan 29, 2019

    @manucorporat
    Contributor
  3. added
    package: react
    and removed on Jan 29, 2019
  4. self-assigned this
    on Jan 29, 2019
  5. jthoms1 commented on Feb 8, 2019

    @jthoms1
    Contributor

    This fixed in release 0.0.4 of @ionic/react

  6. ionitron-bot commented on Mar 10, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  7. locked and limited conversation to collaborators on Mar 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

package: react

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions