Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onPress not working #69

Open
drfarch opened this issue Jul 19, 2020 · 2 comments
Open

onPress not working #69

drfarch opened this issue Jul 19, 2020 · 2 comments

Comments

@drfarch
Copy link

drfarch commented Jul 19, 2020

import { AwesomeButtonProgress } from 'react-awesome-button';
import AwesomeButtonStyles from 'react-awesome-button/src/styles/styles.scss'

function Button() {
return (
<AwesomeButtonProgress
cssModule={AwesomeButtonStyles}
type="primary"
onPress={next => {
// do a sync/async task then call next()
console.log("test");
next()
}}
>
Button

);
}

i tried this code that i get from 'AwesomeButtonProgress basic example' docs

@kian2attari
Copy link

I just went through the same thing. Just replace onPress with action and it should work!

Example:

<AwesomeButton
  type="primary"
  role="button"
  action={() => {
    alert('button pressed');
  }}
>
  Portfolio
</AwesomeButton>

@pierreericgarcia
Copy link

It's a bug, next is the second parameter !

The problem is that the first argument of the onPress's callback function is not the next function but the ref of the <Button/> (so it returns us a <span/>). The next function is actually the second parameter of the callback function.

<AwesomeButton
  type="primary"
  role="button"
  onPress={(ref, next) => {
    // next is the second parameter !
    next();
  }}
>
  Portfolio
</AwesomeButton>

Either the documentation is incomplete, either it's a bug that needs to be fixed. I'll make a PR proposing an update to the current documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants