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

Add a callback function #1

Open
AryanSingh opened this issue Feb 5, 2019 · 7 comments
Open

Add a callback function #1

AryanSingh opened this issue Feb 5, 2019 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@AryanSingh
Copy link

Please add functionality to add a callback function after someone clicks outside a box.

@sag1v
Copy link
Owner

sag1v commented Feb 8, 2019

Can you please provide a use case for this?
When should this callback fire, before or after the state updates and trigger a re-render?

@AryanSingh
Copy link
Author

I have a modal, I want to close the modal when clicked outside it. I used react-trap to check for clicks outside modal, i want to close the modal when clicked outside.

@sag1v
Copy link
Owner

sag1v commented Feb 9, 2019

Not sure i fully understand.
react-trap is already providing the value for you, you can pass it to the Modal as a prop:

<Trap event="click">
    {(trapped, ref) => <Modal innerRef={ref} isOpen={trapped} />}
</Trap>

Is this not answering your use case?

@sag1v sag1v assigned sag1v and unassigned sag1v Feb 9, 2019
@sag1v sag1v added the enhancement New feature or request label Feb 9, 2019
@sag1v
Copy link
Owner

sag1v commented Mar 3, 2019

closing for now. feel free to reopen if you think my solution isn't sufficient

@sag1v sag1v closed this as completed Mar 3, 2019
@sag1v
Copy link
Owner

sag1v commented Mar 17, 2019

I think i realized the motivation here, hence I'm reopening this issue. i think a callback can help indeed

@sag1v sag1v reopened this Mar 17, 2019
@sag1v sag1v self-assigned this Mar 17, 2019
@AryanSingh
Copy link
Author

AryanSingh commented Mar 19, 2019 via email

@sag1v
Copy link
Owner

sag1v commented Mar 19, 2019

Thank you, mostly c# and JavaScript of course

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

No branches or pull requests

2 participants