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

Helix clone-element #13

Open
lilactown opened this issue Jan 31, 2020 · 4 comments
Open

Helix clone-element #13

lilactown opened this issue Jan 31, 2020 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@lilactown
Copy link
Owner

Provide a helix.core/clone-element macro which uses the same props conversion API as $.

@lilactown
Copy link
Owner Author

Having other fns for extracting and manipulating props could be useful as well.

(helix.core/props some-el)
;; => props as a bean

@darwin
Copy link
Contributor

darwin commented Jan 31, 2020

@lilactown lilactown added enhancement New feature or request good first issue Good for newcomers labels Apr 28, 2020
@retro
Copy link

retro commented Mar 22, 2021

I'm interested to work on this feature. I've looked through the code, and it seems that the basic implementation could be as simple as

(defmacro clone-element
  "Clones a React Element with props conversion like in $"
  [element props]
  `^js/React.Element (.cloneElement (get-react) ~element (impl.props/props ~props)))

What I'm not sure about is "helix/propx" attr that is present in some cases. Any tips would be appreciated

@lilactown
Copy link
Owner Author

Hmm. That's a tricky problem, I'll have to think about it. .cloneElement does a shallow merge, which means it will ignore "helix/props".

"helix/props" is only present if you are using the :define-factory feature flag. it's pretty niche. Perhaps I should change the implementation to shallowly convert the props to a JS object inside the factory function, so that they match what the $ macro does at compile time.

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

No branches or pull requests

3 participants