reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
emccue 2021-02-07T03:54:48.044200Z

I want to pass an actual keyword as a prop to a react component

Lu 2021-02-07T08:53:01.046800Z

How about “:hello” and when you read it you just call keyword on that

emccue 2021-02-08T03:57:58.049300Z

I need to pass along namespaced keywords, so not that easy

Lu 2021-02-08T08:51:56.051400Z

(subs (str your-kw) 1) .. this handles namespaced kws too... then you can just call (keyword ..) on the string to have it back as it was

emccue 2021-02-07T03:54:58.044500Z

such that the keyword gets "passed through"

emccue 2021-02-07T03:55:26.045Z

:> and create-element both seem to have the property get stringified in some way

p-himik 2021-02-07T06:46:48.045100Z

You have to encode the props yourself - Reagent doesn't touch JS objects.

juhoteperi 2021-02-07T10:59:04.048700Z

:> converts the props to JS objects automatically, doing same conversion as Reagent does with DOM nodes, snake-case to camelCase, renaming some probs and keywords to strings. create-element or :r> pass the props object as is, but you should pass in JS object as the top-level props, but inside the object you can use whatever Cljs datastructures you want.

p-himik 2021-02-07T11:24:10.048800Z

You can use regular JS objects with :> as well, no? So e.g. #js {:a :b} will make sure that the component receives :b as a keyword.