Fork me on GitHub
#reagent
<
2017-02-28
>
hlolli13:02:09

how does one access the componen's local state

:component-did-mount (fn [this]
(r/set-state this  {:some "state"}))
:reagent-render (fn [this] [:p (str (r/state this))])
a simplification here, but I get an error from this action r/state.

hlolli13:02:28

this works

:component-did-mount (fn [this]
(r/set-state this  {:some "state"}))
:reagent-render (fn [this] [:p (str (r/state (r/current-component)))])
weird

pesterhazy16:02:42

Render doesn't get the comp passed as the first argument

pesterhazy16:02:03

It gets the first prop

juhoteperi16:02:05

:render takes this as argument and :reagent-render the arguments passed to the component

nidu16:02:00

Hello. Am i right that with with-let you can get only initial component arguments values? I suppose i can combine with-let with returning function but is it intended usage?

pesterhazy17:02:43

I never knew. That is a weird API

juhoteperi17:02:46

the docstring is right 🙂

pesterhazy17:02:03

Trust but verify 😉

juhoteperi17:02:51

Btw. if using :render the properties are available using reagent.core/props

juhoteperi18:02:40

props being the first argument to function, children returns the list of rest of arguments

pesterhazy18:02:38

I think that's only true if the first argument is a map btw

pesterhazy18:02:56

otherwise everything is availaible as r/argv