-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Use render props to pass onClick handler to a custom button #74
Comments
If my solution is fine for you, I can contribute for this repo, that should be a quick thing to do 🚀 |
@WPaczula thanks for reporting <MicrosoftLogin
clientId={'id'}
authCallback={authCallback}
>
<MyCustomComponent />
</MicrosoftLogin> Passing custom |
@alexandrtovmach thanks for the replay 😄. I propose using render props pattern, which would look like this: if (render) {
return render({ onClick: login });
} else {
return children ? (
<div onClick={login}>{children}</div>
) : (
<MicrosoftLoginButton
buttonTheme={buttonTheme || "light"}
buttonClassName={className}
onClick={login}
/>
);
} Structuring the code this way would allow the consumers of this library to inform it that the login button was clicked, but it is decoupled from actual implementation of handling the click. They would be able to use it however they like without any impact on their html. |
Sorry for delay =) |
Is your feature request related to a problem? Please describe.
I'd like to style the login button in a custom way. This library creates an additional div with
onClick
handler and there is no way to apply class name to it in a clean way.Describe the solution you'd like
More flexible solution could be a usage of render props with
onClick
handler as a prop calledrender
Describe alternatives you've considered
Other option would be to adjust
children
prop to allow functions. If the function is passed => invoke it withonClick
prop, if it's a jsx element render it in div not to make a breaking changeAdditional context
Proposed API:
The text was updated successfully, but these errors were encountered: