Importing react components from clojurescript

945 views
Skip to first unread message

Quentin Le Guennec

unread,
Aug 18, 2018, 12:15:14 PM8/18/18
to clojur...@googlegroups.com
Hello,

I'm using re-frame lein template with figwheel and reagant.

I'm looking to import a react component (`react-youtube`) from my
clojurescript project.

I found several solutions but either they didn't work either they were
too complex.

Anyone knows an easy way too do it?

Thanks.


signature.asc

Philos Kim

unread,
Aug 18, 2018, 7:58:44 PM8/18/18
to ClojureScript
Recer to the section
'Creating Reagent "Components" from React Components' of the following page.


https://github.com/reagent-project/reagent/blob/master/doc/InteropWithReact.md

Quentin Le Guennec

unread,
Aug 19, 2018, 9:11:30 AM8/19/18
to clojur...@googlegroups.com
Hello, thanks for your answer

That is not what I am looking for.

I am trying to import javascript code into my clojurescript project.
Something you would do with either `require` or `import` in javascript.

The node module I need would have to be specified in `defproject`, then
downloaded when I run `lein deps`

Then in clojurescript, I would have access to that module.
signature.asc

Philos Kim

unread,
Aug 19, 2018, 9:09:06 PM8/19/18
to ClojureScript
The react-flip-move library in the example is written in React JavaScript code.




2018년 8월 19일 일요일 오후 10시 11분 30초 UTC+9, Quentin Le Guennec 님의 말:

Quentin Le Guennec

unread,
Aug 20, 2018, 10:43:35 AM8/20/18
to clojur...@googlegroups.com

It doesn't quite answer everything. I would like a full example of a project using a react javascript component. Do you have an idea where I could find that?

--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.
signature.asc

Philos Kim

unread,
Aug 20, 2018, 12:36:11 PM8/20/18
to ClojureScript
https://github.com/cljsjs/packages/tree/master/react-flip-move

Add the following to :dependencies section in project.clj

[cljsjs/react-flip-move "3.0.1-1"]


Your cljs code:

(ns application.core
(:require cljsjs.react-flip-move))

(def flip-move (r/adapt-react-class js/FlipMove))

(defn my-list [data]
[:div
[:ul
[flip-move {:easing "cubic-bezier(0, 0.7, 0.8, 0.1)"}
(map (fn [[k v]] (vector :li {:key k} v)) (:list @data))]]

[:button.btn.btn-primary
{:on-click #(swap! data update-in
[:list] (fn [s]
(into {} (shuffle (seq s)))))}
"Shuffle"]])

Dusan Miloradovic

unread,
Aug 20, 2018, 12:37:16 PM8/20/18
to clojur...@googlegroups.com
I think the easiest way to do it is using the shadow-cljs. Here is the example: https://github.com/shadow-cljs/examples/tree/master/cljs-react-app


Alan Thompson

unread,
Aug 20, 2018, 7:32:54 PM8/20/18
to clojur...@googlegroups.com
If you clone this template project it provides examples of 3 ways in "import" native JS code into a CLJS project (see "dino.js" etc).

g...@github.com:cloojure/cljs-template.git


   

Alan Thompson

unread,
Aug 20, 2018, 7:33:22 PM8/20/18
to clojur...@googlegroups.com
Meant to paste the URL:   https://github.com/cloojure/cljs-template  

Alan
Reply all
Reply to author
Forward
0 new messages