Live data from Hacker News

Build Your Own React

pomb.us

61–70 of 114 posts

Re: Build Your Own React

#61
post #60

Forget building my own React, I want to build how you did the presentation! It’s a great concept!

I agree, though, it's a shame there's no fallback for when there's no javascript.

I'll assume this was meant with irony, and applaud you for this comment.

Re: Build Your Own React

#62
post #5

Very, very nice. His presentation library is available as well! https://codesurfer.pomb.us/ https://github.com/pomber/code-surfer/blob/code-surfer-v2/re...

Yeah the presentation effect on code is super cool. Yet on mobile I didn't feel that it was particularly helpful as it covered about half the screen height and I couldn't clearly skim the content.

Re: Build Your Own React

#63
I think that inverting the order, putting the text on the left and code on the right would work much better.

For me, it felt quite unnatural to go against the normal reading direction. I believe that because we read left-to-right, and the additional content is usually on the right, it would be easier for the eyes to search for the examples on the right rather than backward. It felt very distracting.

Great content though!

Re: Build Your Own React

#64
post #51

Earlier quoted context omitted.

Yeah I'm not a fan at all of react-router because it's too dependent on React. For redirecting, for example, they recommend you render a component. Which is just bananas to me.

It's not really bananas when you actually start to think of everything 'as components', and consider that 'render' can neatly, declaratively describe behaviour, not just the DOM.

That _is_ how I think about components, but it's still bananas. Render does not neatly describe this behavior because it necessitates setting unnecessary state. That's gross.

Usually when I need to trigger a redirect, I'm in some business-level function. So to redirect this way, I would need to set some state in my store, re-render, then hit the conditional, which would redirect, probably unset that state, and then probably trigger some additional business logic.

When really all I want to do is in the business function, directly trigger the redirect and maybe some other logic without any indirection. redux-react-router exists, but it's API is still obtuse compared to something like redux-first-router.

Re: Build Your Own React

#65
post #51

Earlier quoted context omitted.

It's not really bananas when you actually start to think of everything 'as components', and consider that 'render' can neatly, declaratively describe behaviour, not just the DOM.

'render' should render, because that's what the function name says. If you're using it for behavior then you're not using it for the intended purpose.

Now that hooks exist, this should definitely be the case. Before, HoCs / components with render prop functions were actually useful for doing some additional not-directly-render related work.

Re: Build Your Own React

#66

Earlier quoted context omitted.

Yeah I'm not a fan at all of react-router because it's too dependent on React. For redirecting, for example, they recommend you render a component. Which is just bananas to me.

The alternative would be to write a side effect inside your `render()` function, which is illegal -- it breaks the new Concurrent mode rendering, which can call render() speculatively. I mean, I see why it's intuitively unappealing to you, but there are perfectly good reasons for the design.

There are "perfectly good reasons" in the sense that if you artificially limit yourself to using the React component tree to manage routes, yes it makes sense how they arrived at this solution. But after dealing with it for a while, it's just so obviously not the correct approach, and it's crazy to me that it's the defacto router. Cargo culting at its finest. The router could exist outside of or at a higher level than the component tree.

Re: Build Your Own React

#69
I really hate the layout and the annoying, distracting, animated garbage on the left side of the page.

Maybe it isn't rendering properly in my browser, but I would greatly prefer a simple, wide, vertical layout.

Re: Build Your Own React

#70

Earlier quoted context omitted.

The alternative would be to write a side effect inside your `render()` function, which is illegal -- it breaks the new Concurrent mode rendering, which can call render() speculatively. I mean, I see why it's intuitively unappealing to you, but there are perfectly good reasons for the design.

There are "perfectly good reasons" in the sense that if you artificially limit yourself to using the React component tree to manage routes, yes it makes sense how they arrived at this solution. But after dealing with it for a while, it's just so obviously not the correct approach, and it's crazy to me that it's the defacto router. Cargo culting at its finest. The router could exist outside of or at a higher level tha…

It's the defacto router because it has gone through many iterations, has lots of users, is easy to bring into a React app, and doesn't fight w/ React, it works with it. Plus there are a variety of approaches to declaring routes. [0]

I'm not sure I see how obvious it is that a is wrong. But that's fine, I take your point that it's not particularly intuitive.

I'm of the opinion that routing, in general, is a function of application state - and I like to manage my application state with Redux - so I will often also mix in connected-react-router [1]. This lets you do navigation w/ an imperative API [2].

[0] https://github.com/ReactTraining/react-router/tree/master/pa...

[1] https://github.com/supasate/connected-react-router

[2] https://github.com/supasate/connected-react-router/blob/mast...

Post reply on HN