For this code,
what is :> in (defn root []
[:> rn/View {:style (:container styles)}
https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md
I guess this is a better suited doc: https://github.com/reagent-project/reagent/blob/master/doc/InteropWithReact.md#creating-reagent-components-from-react-components
Thanks. Is there a quick way to see the translated output of cljs to some vanilla js like what http://babeljs.io does ?
No, because there's no translation step.
What exactly are you trying to figure out?
Currently no. The link solves the actual question.
Hello, I'm trying to use https://github.com/ivmarcos/react-to-pdf but I have to admit I have no clue how to handle this kind of React syntax (function in component) with reagent. Any tips?
const ref = React.createRef();
<div>
<ReactToPdf targetRef={ref} filename="div-blue.pdf">
{({toPdf}) => (
<button onClick={toPdf}>Generate pdf</button>
)}
</ReactToPdf>
<div style={{width: 500, height: 500, background: 'blue'}} ref={ref}/>
</div>
The post above yours has the two doc links in its thread. :)
haaaa thanks. Next time I will scroll up a bit !
Or better yet, just read the titles and subtitles in the Reagent documentation files. :) 99% of the time the answer is there.
Hi everyone, my components are starting to have a lot of control flow code inside. Any suggestions for the best practice to split things up? Example:
(defn my-component [args hidden? collapsed? suppress-error-msg?]
...)
Thank you 🙂Check out how re-com is implemented.
One note on that though - personally, I would advise against using [& {:keys [...]}]
in favor of using [{:keys [...]}]
.
Thank you! I'll take a look
one thing to consider is breaking up your component into separate components that a consumer can get more control from:
(defn some-component []
(let [collapsed? (r/atom false)]
(fn []
[collapsable {:collapsed? @collapsed}
[my-component-body ,,,]])))