Fork me on GitHub
#rum
<
2020-05-15
>
Aron06:05:11

neovim is an ide?

didibus07:05:03

What's the idiomatic way to have a child component return something for the parent component to use?

Roman Liutikov07:05:35

Depends on what you are trying to achieve

Roman Liutikov07:05:48

If it's something other than hiccup/UI, then normally you'd pass a callback into the child component

didibus07:05:25

Like say I want acces to the value of a textarea from the parent?

didibus07:05:29

But assume I don't want to just use innerHTML on the element

Roman Liutikov07:05:05

Keep the state in the parent and pass it down to text area

didibus07:05:43

Hum... like pass an atom in for the child to swap! ?

didibus07:05:13

That's what I had right now, though I guess things are a bit ugly. Because I'm trying to access the code mirror value, where code mirror is created in the did-mount function. And the state on defcs of the render function runs before did-mount.

Roman Liutikov07:05:37

Pass the value and a callback that takes a new value and updates the state

Roman Liutikov07:05:51

That's a common practice in React

Roman Liutikov07:05:52

I see, for that you can assign a listener onto code mirror instance and call the callback there

didibus07:05:49

My knowledge of react and js is very minimal, what is a listener?

Roman Liutikov07:05:54

That should be a part of codemirror API, I don't know exactly, just an event handler that is called on every change

didibus07:05:46

Ah ya, there is a change event handler. I guess I thought since I only care to grab the value when someone clicks a button. And my parent component is basically a combination of codemirror + button. My thought was to have in the on-click of button just grab the value. So I thought surely I can somehow return the codemirror instance to the parent so I can use it in the button on-click

didibus07:05:40

But say I did use the on-change event for code mirror. I'm still confused how I'm supposed to pass the callback into the did-mount ?

Roman Liutikov07:05:34

lifecycle mixins take rum state where you can lookup args

Roman Liutikov07:05:56

Also if you are using latest rum, same can be done a bit easier with hooks

didibus07:05:19

Oh, with :rum/args ? on the state?

didibus07:05:47

I am using latest rum, I didn't fully understand hooks yet so haven't tried them out

didibus07:05:52

Is it possible to do all things with hooks that the mixin callback let you do?

didibus07:05:51

Hum, interesting, maybe I'll spend a bit more time reading about them and trying to understand how to use them in rum