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.

Callback not Accessible

See original GitHub issue
const PaystackHookExample = () => {
        const initializePayment = usePaystackPayment(config);
        return (
            <div>
                <button onClick={() => {
                    initializePayment()
                }}>Paystack Hooks Implementation</button>
            </div>
        );
    };

Callback isn’t accessible using this method

Here is a quick repro https://codesandbox.io/s/gallant-cdn-9ddke

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Tooluloopecommented, Jun 24, 2020

@iamnotstatic you need to pass in those callbacks to intializePayment

const PaystackButton = ({ text, className, children, onSuccess, onClose, ...others }: PaystackButtonProps): JSX.Element => { const initializePayment = usePaystackPayment(others); return ( <button className={className} onClick={(): void => initializePayment(onSuccess, onClose)}> {text || children} </button> ); };

the code sandbox link has been edited so you can understand better

0reactions
Tooluloopecommented, Jun 24, 2020

Requires callback to be passed to initializePayment

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - How to access the correct `this` inside a callback
However, I'm not able to access the data property of the created object inside the callback. It looks like this does not refer...
Read more >
How to access the correct this inside a callback
We explore the methods for accessing the correct this in a callback by explicitly forcing a context binding to point to our object...
Read more >
JavaScript Callbacks Variable Scope Problem - Pluralsight
In this free JavaScript guide, you'll learn how to fix the common JavaScript callbacks variable scope problem. This step-by-step JavaScript ...
Read more >
Callback not working properly if I dont have debugger in my ...
Sounds like your callback function not really works. Callbacks/promises/async-await is used for asynchronous stuff when Innovator shall wait for another client ...
Read more >
Callback after Sign-up Not working - Auth0 Community
This works fine, but after signing up, Auth0 calls my /register route in an infinite loop. It doesn't call localhost:3000/callback (which I ...
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