Fork me on GitHub
#rum
<
2020-04-23
>
Roman Liutikov09:04:20

@cjsauer To be precise about that, since we are aligning with React itself in this regard you'll still get stuff like this https://codesandbox.io/s/silly-faraday-mb94d?file=/src/App.js

cjsauer13:04:36

@roman01la are you referring to the use of hooks? Scanning thru the PR. I’m noticing the use of rum/use-state in the examples, which I honestly had no idea even existed! I opened up a PR adding descriptions of those wrappers to the readme: https://github.com/tonsky/rum/pull/209 I also see you’ve implemented request-render in terms of .setState. Does Rum actually make use of (.-state component), or does this simply “trick” React into scheduling a render?

Roman Liutikov13:04:17

no not hooks, but how the caret jumps to the end of input in that example

cjsauer13:04:46

Ahh yea, I see now. I opened on mobile initially.

cjsauer13:04:46

I’ve had this issue in the past. Will be great not to worry anymore.

Roman Liutikov13:04:14

well this one in particular is just the way how inputs work on the web

Roman Liutikov13:04:56

but issues like skipped characters or jumping caret when typing in text won't be a thing in rum anymore when we merge that pr

cjsauer14:04:07

> you’ll still get stuff like this Ah I misread. I see what you meant now.

Roman Liutikov14:04:04

> I also see you’ve implemented request-render in terms of .setState. Does Rum actually make use of (.-state component), or does this simply “trick” React into scheduling a render? That's just to schedule an update, yes. We might change this a bit in future, but the idea is that we should schedule updates using React's usual mechanism.

Roman Liutikov14:04:08

> Scanning thru the PR. I’m noticing the use of rum/use-state in the examples, which I honestly had no idea even existed! I opened up a PR adding descriptions of those wrappers to the readme: https://github.com/tonsky/rum/pull/209 Thanks. I'll merge this after https://github.com/tonsky/rum/pull/205

👍 4
Roman Liutikov14:04:15

There's a high possibility that Rum could easily adopt Hooks and Suspense w/o breaking existing users, which is exciting

Roman Liutikov14:04:57

I've already added Suspense component and lazy loading support for code-splitted components

Aron14:04:03

I have not been able to rationalize suspense so far

Aron14:04:30

and I am saying this as someone who has been using concurrent rendering since like 2016

Aron14:04:46

and hooks are the best thing that happened to react, imho, but I still don't like using functions that are effectively Views, to manage state

Roman Liutikov15:04:45

Yeah React gets complex and I'm not sure I like this, it becomes harder and harder to integrate with it

Aron15:04:35

Afaik, calling in concurrent mode render on the root node with a full state is not different from just calling this.setState

Aron15:04:43

the event system assumes those are low level updates

Aron15:04:16

so I am going to hook up datascript one day to it, and see how far I can push it, because I think it goes all the way 🙂

Roman Liutikov15:04:39

I've been looking into useMutableSource, no opinions atm

Roman Liutikov15:04:34

> Afaik, calling in concurrent mode render on the root node with a full state is not different from just calling this.setState Is there anything to read about this somewhere?

Roman Liutikov15:04:36

That would be good news

Aron15:04:38

found it 😄

Aron15:04:01

it might've been true even before Fiber

Aron15:04:45

someone even answered there, maybe you see who 😄

Aron15:04:51

funny, this life 🙂

Roman Liutikov15:04:28

How that would work with subscriptions deep in UI tree + memoized components?

Roman Liutikov15:04:53

I guess this is just two different models of propagating updates

Roman Liutikov15:04:46

perhaps React context can be used in such cases

Aron15:04:52

the naiv thing is just to pass props, it's trivial if you attach static query props to components, I am not sure if rum does this? I think om next works like that

Aron15:04:07

context is the idiomatic react way, but it's surprisingly slow

Roman Liutikov15:04:21

yeah, I never used it actually in cljs

Aron15:04:58

The thing is, as long as you want locally managed state, it's going to be difficult. The component's scope needs to access the data which means that either through an argument, through the hidden argument called .this or through a global.

Aron15:04:24

or, of course, as a local variable to that scope, but then good luck sharing it with children or - even worse- other parts of the application

Aron15:04:23

https://reactjs.org/docs/lifting-state-up.html this part of the react docs is the biggest admission of failure (and don't get me wrong, I quite like React, probably would use it even when it's not necessary 🙂 )

Aron16:04:12

after all, the idea of local state is built on the idea of encapsulation from OOP, but if you start moving state up, you by definition break all kinds of OOP principles