Fork me on GitHub
#fulcro
<
2019-04-12
>
neupsh00:04:21

Why can't I select any values in the select dropdown in this RootComponent?

currentoor00:04:39

@U3MRWH35M could you please make a github gist out of this instead?

currentoor00:04:00

no offense, i just don’t want to download random files strangers post on the internet

neupsh00:04:11

@U09FEH8GN none taken 🙂 Done 🙂

currentoor00:04:16

ok so there’s a lot to do on this code

currentoor00:04:07

- the actual UI root component cannot have an ident (work spaces will make a wrapper root for you if you have ::f.portal/wrap-root? true, which you do not)

currentoor00:04:08

- initial state needs to compose to the root and be setup the correct way

currentoor00:04:00

there are a lot of new concepts involved in fulcro, once you understand them it’s really powerful stuff, but there is definitely a learning curve

currentoor00:04:28

have you read the book?

currentoor00:04:36

that’s a good place to start

currentoor00:04:53

if you work your way through those two resources you should have a much better grasp on what normalized app state means and when to use idents and when idents don’t make sense

neupsh00:04:07

Thank you @U09FEH8GN I have been following clojure since 2013, but never got to use it in real world. Now I have decided to actually build something on my spare time using fulcro to get into it. I have gone through the book and the videos above (actually multiple times) but I have still not figured out a lot of things.

currentoor00:04:07

perhaps it’s better to understand things conceptually first

neupsh00:04:08

Do you know where can i find more details on "idents" and "queries"? I have read the fulcro book, which is amazing, but still unsure about these

currentoor00:04:23

the devcard based tutorial is pretty good

currentoor00:04:39

a little dated but most of it is still very relevant

neupsh00:04:36

I have setup the project using the fulcro lein template (which sets up the shadow-cljs based project), and now want to try it in my local

currentoor00:04:00

oh wait no the tutorial is too out of date

neupsh00:04:01

does the devcard based tutorial still work with the new template?

currentoor00:04:12

no it doesn’t

currentoor00:04:33

the book has plenty of actual code examples

neupsh00:04:51

I have setup the workspace (this root component was in a quick scratch workspace i setup to try it out)

currentoor00:04:51

all the demos in the book are in the source of the main fulcro repo

currentoor00:04:59

you could study those

neupsh01:04:19

Do you know why that dropdown does not let me select the value? I have updated the gist to correct the ident/queries and separate root component from actual

currentoor01:04:47

well it depends on the implementation of mui/TextField

currentoor01:04:14

my guess you need to pass in a on-change handler or some other prop

neupsh01:04:19

oops i should have been more clear

neupsh01:04:01

mui/TextField is react component

currentoor01:04:14

i realize that

currentoor01:04:20

you need to read it’s docs

currentoor01:04:34

it takes in a onChange prop

currentoor01:04:11

use that to transact a mutation and update the value you’re passing in

neupsh01:04:05

hmm looks like i needed to actually keep the state as well for the component I was thinking the "select" part will be handled by the component

neupsh00:04:23

Disclaimer: very newbie code 🙂

tjh.xbow02:04:35

How can I using Antd UI component in fulcro ?

beetleman07:04:09

@tjh.xbow its how i wrapp react-select

(ns example.react-select
  (:require ["react-select" :default ReactSelect]
            [fulcro.incubator.ui.core :as uc]))

(def ui-react-select (uc/component-factory-localized ReactSelect))
more info https://medium.com/@wilkerlucio/using-any-react-ui-kit-with-fulcro-82cce271b9cc

👍 8
beetleman07:04:34

I have few react libs which i use in my code base and this ☝️ work for me (disclaimer: im fulcro newbie)

tjh.xbow07:04:57

@mateusz.probachta Thanks for you information

levitanong08:04:50

When a component doesn’t implement IQuery, is there a difference between normal props and computed props?

claudiu09:04:12

@U0BR5D7A6 Don't think so. Think computed is just cool for when you're doing transact with the component this so that on refresh those don't get lost. When I don't need query or react life-cycle stuff I just write them as defn

levitanong09:04:17

Yeah, that’s what I figured. I wrote a higher-order component that maintains some local state (because react lib interop) and I realized I don’t really use prim/computed for these things.

currentoor15:04:05

@U0BR5D7A6 correct there is not difference in that case

currentoor15:04:27

when a component has a query, props have to come from app state (which should only have serializable data, i.e. not stuff like callbacks)

currentoor15:04:54

typically you pass callback props in as computed

currentoor15:04:31

but you can also pass in other data that is not queried for but still relevant in some way

levitanong16:04:11

thanks for the clarification, @U09FEH8GN 🙂

👍 4
eoliphant18:04:34

Hi I have a quick question, it may be some sort of CLJS/JS interop issue but i’ve not figured it out. Have a project that’s using fulcro and MUI, and trying to implement something like the following

; For this in JS
...
<Drawer
        className={classes.drawer}
        variant="permanent"
        classes={{
          paper: classes.drawerPaper,
        }}
      >
; Have this in a fulcro component
...
:css [[:.drawer {:width      "240px"
                    :flex-shrink 0}]
         [:.drawer-paper {:width "240px"}]]
...
(mui/drawer {:className drawer 
                 :variant   :permanent
                 :classes   {:paper drawer-paper}}
Using the component-factory stuff in incubator etc. The class is applied to the parent drawer with no problem. But for some reason, the child paper element isn’t getting the class applied. It seems like it should be straightforward, but no idea what’s causing this

currentoor18:04:45

@U380J7PAQ do you mind sharing more of the source of this component?

eoliphant18:04:15

also was wondering if this: is causing the probelm http://book.fulcrologic.com/#_the_render_method

currentoor18:04:52

what about render?

eoliphant18:04:03

the :classes key that exists for dom, etc compoments

currentoor18:04:10

well that depends on the definition of mui/drawer

claudiu18:04:10

have you tried with (mui/drawer (cljs->js {...}) ?

currentoor18:04:25

what component-factory are you using?

currentoor18:04:32

you mentioned it was in the incubator?

eoliphant18:04:32

(defsc PageContent [this props _ {:keys [drawer drawer-paper]}]
  {:query []
   :css [[:.drawer {:width      "240px"
                    :flex-shrink 0}]
         [:.drawer-paper {:width "240px"}]]}
  (let [tst    (m.utils/class :drawerPaper props)
        tst-js (clj->js tst)]
    (log/debug "cl obj" (.-paper (clj->js {:paper drawer-paper})))
    (mui/drawer {:className drawer 
                 :variant   :permanent
                 :classes   {:paper drawer-paper}}
      (log/debug "drawer" (m.utils/class :drawer props))
      (log/debug "dp" (m.utils/class :drawerPaper props))

      (div {:className (m.utils/class :toolbar props)})
      (mui/list-mui
        (mui/list-item {:button true
                        :key    "Text"}
          (mui/list-item-icon (m.icons/menu))
          (mui/list-item-text {:primary "Text"}))))))

eoliphant18:04:00

yeah I’m using the non-localized one at the moment

eoliphant18:04:27

e.g. (def drawer (uc/component-factory Drawer))

currentoor18:04:27

right, sorry i meant what namespace is uc?

currentoor18:04:59

ah i found it

eoliphant19:04:02

ah sorry lol [fulcro.incubator.ui.core :as uc]

currentoor19:04:36

yes unfortunately that will re-write :classes

eoliphant19:04:51

ugh well at least we know what it is lol

currentoor19:04:33

yeah you’re best bet is to write your own component factory method

currentoor19:04:39

for JS interop i prefer a very light weight version

currentoor19:04:45

(defn factory-apply
  [class]
  (fn [props & children]
    (apply js/React.createElement
      class
      (clj->js props)
      children)))

currentoor19:04:24

for situations like this where fulcro’s stuff collides with the JS lib

eoliphant19:04:01

Yeah, I’ll pop that in for now, then ping wilker about preferred ways ways to get around it in the lib

eoliphant19:04:19

ah yeah, i think i see it now. since the incubator stuff is ultimately delegating to the fulcro client dom stuff

eoliphant19:04:35

the :classes stuff is added there

currentoor19:04:19

yup that’s what happens when keys don’t have namespaces…

currentoor19:04:48

but no one wants to type ::prim/classes everytime even though it’s probably the better thing to do

currentoor19:04:54

happy to help simple_smile

eoliphant19:04:57

my teams give me a hard time about my “naming rants”

eoliphant19:04:58

I’ve taken to just not helping if their code has unqualified keywords lol ’fix that, then get back to me: lol