reagent

tokoma 2019-07-03T01:51:25.236100Z

@tokoma1 has joined the channel

tokoma 2019-07-03T02:03:17.240600Z

I'm trying to re-write a material-ui example with reagent. I am writing cljs code for the following page. https://material-ui.com/getting-started/page-layout-examples/sign-in/ The js code is as follows: https://github.com/mui-org/material-ui/blob/master/docs/src/pages/getting-started/page-layout-examples/sign-in/SignIn.js Currently, FormControlLabel and LockOutlinedIcon don't work. I have re-wirited the following js code into cljs code.

js
import FormControlLabel from '@material-ui/core/FormControlLabel';
import LockOutlinedIcon from '@material-ui/icons/LockOutlined';

          <FormControlLabel
            control={<Checkbox value="remember" color="primary" />}
            label="Remember me"
          />

        <Avatar className={classes.avatar}>
          <LockOutlinedIcon />
        </Avatar>
clojure
(ns my-comp.login
  (:require ...
            ["@material-ui/core" :refer [.. FormControlLabel]]
            ["@material-ui/icons" :refer [LockOutlinedIcon]]
            ["@material-ui/core/styles" :refer [makeStyles]]
            ))
.....
[:> FormControlLabel {:control [:> Checkbox {:value "remember" :color "primary"}] :label "Remember me"}]
.....
[:> Avatar {:class "classes.avator"}
  [:> LockOutlinedIcon]
]
.....
The is an error in JS console:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
I knew there are some problems in my cljs code and trying to fix the problem, but I couldn't find the resolution. I will be happy if anybody give me some help.

valtteri 2019-07-03T04:52:35.245400Z

Hi @tokoma1! When you pass another component as props to a MUI component you need to pass a real react component instead of a reagent component. You can use reagent.core/as-element, for example.

[:> FormControlLabel {:control (r/as-element [:> Checkbox {:value "remember" :color "primary"}]) :label "Remember me"}]
Remember that :> turns react component into something that reagent understands but if you hand reagent component to a react-lib it probably doesn't know what to do with it.

Ahmed Hassan 2019-07-03T06:47:03.247Z

@valtteri does using :> means that we can use kebab-case keywords as arguments to components?

valtteri 2019-07-03T14:23:07.250600Z

@ahmed1hsn :> is shorthand for reagent.core/adapt-react-class. I warmly suggest reading through this http://reagent-project.github.io/docs/master/InteropWithReact.html

👍 1
valtteri 2019-07-03T14:29:53.250800Z

And about kebab-case... Reagent automatically converts prop keys from kebab-case to camelCase so you can write code that looks like more idiomatic Clojure.

👍 1
Daniel Slutsky 2019-07-03T08:10:07.247200Z

@daslu has joined the channel

Daniel Slutsky 2019-07-03T08:10:50.248100Z

Hi all. : ) Does anybody know of a Clojure library that implements Reagent-like reactions on the JVM? https://reagent-project.github.io/docs/master/ManagingState.html

Daniel Slutsky 2019-07-03T17:08:40.253800Z

@zcaudate just told me about https://github.com/aaronc/freactive.core .

metehan 2019-07-03T12:51:41.249400Z

hi there is an operator I don't understand since it's all special characters I couldn't google it what :<- does?

metehan 2019-07-03T12:51:44.249500Z

jthibaudeau 2019-07-03T13:06:56.250100Z

the comments here do a good job explaining it

metehan 2019-07-03T13:08:24.250300Z

thank you I am checking it

👍 1
stefan 2019-07-03T15:33:17.253Z

like that font

metehan 2019-07-04T10:11:09.254400Z

@stefan.age https://github.com/tonsky/FiraCode this is the font

👍 1
tokoma 2019-07-03T15:11:00.252900Z

@valtteri Thank you for your help. Great ! It worked with your code ! I could also understand react components and reagent components.

👍 1