-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support for custom callbacks #7
Comments
Hi @troels-a, I would be happy to review this as a PR, I see some small changes that we might need to make before we can merge this, but I think it might be a useful feature. 💪 |
Nice! I'll get the pr ready asap. |
When will the PR be fixed and merged? I need the callbacks too. Thanks |
Hi @cristinaITdeveloper, the PR is not ready yet and we still didn't find real use cases in our projects to justify working on this specific feature, but if you have any examples to share I would be happy to discuss them. |
I answered in issue #13 |
Hi, I have the case of Microsoft Clarity that in early 2025 requires the configuration of cookie consent via API by setting an appropriate value. I would need a way to simply set Is there another way besides custom callbacks? Thanks! |
Hi @m00tt, thank you very much for sharing this use case. I see your point, and I understand that this is something that would not work well with React components alone, as you need to trigger a side effect without rendering anything. My main concern with enabling the callbacks directly from Iubenda is adding something that might start to work inconsistently compared to the rest of the library. Maybe it would be better if I could wrap Iubenda's callbacks in a dedicated subset of callbacks that behave exactly the same as the rest of this library, so we can have the best of both approaches but with consistent behavior. What do you think about this? Do you have any suggestions about what events would really matter? In the meanwhile, would you mind trying this approach? This should achieve a similar results but using a component with a 'use client';
import { useEffect } from 'react';
import { useIubenda } from '@mep-agency/next-iubenda';
const ConsentAwareRunner = () => {
// See https://github.com/mep-agency/next-iubenda/blob/8fafe8fde7f5c1f458863643e252f8a9adae5837/src/contexts/IubendaContext.tsx#L20-L49
const { userPreferences } = useIubenda();
useEffect(() => {
// Do things whenever the userPreferences object changes
}, [userPreferences]);
// Return an empty component so this can be placed anywhere in the DOM.
// This is kinda hacky, but serves the purpose of having a component with side effects only.
return <></>;
};
export default ConsentAwareRunner; @cristinaITdeveloper maybe this can help you too? |
Hello
I found myself in need of support for custom callbacks so I forked this repo and tried it out. It seems to work great:) Let me know if you want me to create a PR for this. Thanks for the work on this repo btw - great stuff.
main...troels-a:next-iubenda:main
Best,
Troels
The text was updated successfully, but these errors were encountered: