Confused over use of cloneElement
in useModalOverlay
hook
#4611
aktiga-inc
started this conversation in
General
Replies: 1 comment 1 reply
-
That's a pattern called Render Props https://legacy.reactjs.org/docs/render-props.html but in this instance, the prop just happens to be children. So we can call children, which will return a React Component, and then we can pass props to that newly created component. You can think of it a little like currying as well. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been looking at the docs for the
useModalOverlay
hook, and I'm really confused over the use ofcloneElement
displayed there. Well, the confusion isn't necessarily with the use ofcloneElement
but what is being passed to it.The code is as follows:
I'm not familiar with the use of
children
here. I was not aware thatchildren
could act as a function that could be passed arguments.Would anyone be able to offer some clarification to this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions