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

$ error when used with native components #61

Closed
wilkerlucio opened this issue May 31, 2020 · 5 comments
Closed

$ error when used with native components #61

wilkerlucio opened this issue May 31, 2020 · 5 comments

Comments

@wilkerlucio
Copy link
Contributor

wilkerlucio commented May 31, 2020

Hello,

I found a bug in the $ with native components.

Reproduce example:

($ "div" {:style #js {:flex 1}})

This gets an error of Error: [object Object] is not ISeqable

I did a little dig, the problem seems to be in this line here: https://github.com/Lokeh/helix/blob/37aca5e65704da96915a4435e6825da4e4de3af7/src/helix/impl/props.cljc#L57

At my example, this ends up calling seq with a JS object, which triggers the error.

@wilkerlucio wilkerlucio changed the title $ fn version error when used with native components $ error when used with native components May 31, 2020
@wilkerlucio
Copy link
Contributor Author

wilkerlucio commented May 31, 2020

Ok, I just figured that on native components we can't send :style as js-obj.

This leads to a confusing situation in React Native, because some of the components there are native (string-based) and others are not (for example, View is a native component, but Button is not), and then figuring when one style should be used over the other gets confusing.

Maybe Helix could always accept the #js version as well, so the client could wrap those consistently?

@wilkerlucio
Copy link
Contributor Author

Another option could be some validation at dev mode to let the user know that it was supposed to use a clojure or a js map in each case.

@alidcast
Copy link
Contributor

alidcast commented May 31, 2020

it can maybe check (or (sequential? x) (map? x)) instead, those operations don't seem to throw errors for js objects

@tekacs
Copy link

tekacs commented Jun 5, 2020

As it stands I end up having to do {:style (bean style) somewhat often, when a style is passed to me either from a library or the result of Helix's own conversion.

@lilactown
Copy link
Owner

Thanks for reporting. @tekacs your use case is very motivating. I'll release 0.0.12 with a fix soon!

lilactown added a commit that referenced this issue Jun 5, 2020
Fix #61: allow JS objects in `:style` prop for "native" components
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

4 participants