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

with-key and with-ref Removing children? #252

Open
zonotope opened this issue May 30, 2022 · 2 comments
Open

with-key and with-ref Removing children? #252

zonotope opened this issue May 30, 2022 · 2 comments

Comments

@zonotope
Copy link

The rum.core/with-key and rum.core/with-ref functions call the underlying React .cloneElement function to create a new React component that includes the supplied key or ref, respectively. Both with-key and with-ref use full function signature version of .cloneElement and pass nil for the optional last argument corresponding to the new component's children. This leads to the resulting component missing the children of the original. If the smaller arity function signature is used omitting the nil, the resulting component will have all of the original component's children.

Is this intended? If so, what is the proper way to use with-key and with-ref so the resulting components also includes the original component's children?

If this was not intended, I have defined these functions as a workaround that works for me:

(defn with-key
  [elt k]
  (js/React.cloneElement elt #js {"key" k}))

(defn with-ref
  [elt r]
  (js/React.cloneElement elt #js {"ref" r}))
@tonsky
Copy link
Owner

tonsky commented May 31, 2022

Probably not intended. PR?

@zonotope
Copy link
Author

Will do. I'll probably have time to make one this weekend.

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

No branches or pull requests

2 participants