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.
Build Your Own React
61–70 of 114 posts
Re: Build Your Own React
#62Very, very nice. His presentation library is available as well! https://codesurfer.pomb.us/ https://github.com/pomber/code-surfer/blob/code-surfer-v2/re...
Re: Build Your Own React
#63For 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
#64Earlier 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.
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
#65Earlier 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.
Re: Build Your Own React
#66Earlier 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.
Re: Build Your Own React
#67Re: Build Your Own React
#68Re: Build Your Own React
#69Maybe it isn't rendering properly in my browser, but I would greatly prefer a simple, wide, vertical layout.
Re: Build Your Own React
#70Earlier 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…
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...