4 ms·
>You don't get much simpler than Redux. Not true. With Redux you write reams of actions and reducers and other such unnecessary crap in the name of state manag
by petilon 8y ago
>You don't get much simpler than Redux.
Not true. With Redux you write reams of actions and reducers and other such unnecessary crap in the name of state management, when in fact most client apps don't have state, all they do is fetch data from the server, display it, send updates back to the server.
React used to be a simple lib, now it is getting more and more complicated. Look at the libs I mentioned they are way simpler.
>you don't even have to use JSX
But JSX is the good part of React. You get compile-time checking of your expressions if you use TypeScript and you get syntax coloring, intellisense etc for both HTML and JavaScript.
- s_y_n_t_a_x 8y agoIf you don't need state, don't include it. That's the beauty of React. But as far as a state management lib goes, Redux is one of the simplest, go look at the source. I agree JSX is very nice. It's one of the best features of React, and another reason React is a great templating lib. My point was you don't need it. React does a lot of other nice things like browser compatibility, event management. If you want a smaller implementation, use preact or some other template lib. When dealing with React and Redux you are just dealing with functions. You could do everything in pure functions.
- petilon 8y agoReact requires too much incantations, rituals and ceremony. You have props and state, context, error boundaries, refs, keys, you have to figure out where state should live, etc. You make a component that contains state. Then you want to use it in a component hierarchy -- now the component is supposed to have props not state. You make a component that has props, now you want to use it at the top level -- now the component is supposed to have state, or have an otherwise unnecessary wrapper. You don't have to deal with any of that crap. The best part of React is DOM diffing and incremental screen update. Obviously this is only useful if your application needs to update screens it previously rendered. In fact I'd argue that React is only useful if you need to incrementally update complex screens, because simple screens can be re-rendered completely and no one will know the difference. Very few applications need to incrementally update complex screens. If your application doesn't have this need you can use simpler technologies that don't have the same "Care and feed" requirements of React, such as UIBuilder: https://github.com/wisercoder/uibuilder https://github.com/wisercoder/uibuilder
- s_y_n_t_a_x 8y agoYou don't have to deal with any of that crap when you deal with react. Just write pure functions as components. The arguments are the props.
- petilon 8y agoThen you aren't benefiting from React at all. The point of React is DOM diffing, which you trigger using setState method.
- s_y_n_t_a_x 8y agoWhen you change the props of a component it re-renders. Just because you use pure functions doesn't mean you don't get DOM diffing, that's silly.
- petilon 8y agoAt some point you have to have state. See where "state should live" here: https://reactjs.org/docs/thinking-in-react.html https://reactjs.org/docs/thinking-in-react.html But the very fact that we're having this debate is proving my point. React's programming model is unnecessarily complicated. JavaScript + DOM is all you need. The simple libs (each less than 500 lines) I pointed to get you close to this without sacrificing productivity or code maintainability while keeping the programming model simple.
- s_y_n_t_a_x 8y agoTo reply to your last comment, each project is different, and if you just want a few things on a page, sure use a small lib like what you suggested. But at a certain point you start reinventing the wheel and no other developer will be able to jump into it. You need a framework for large projects with a team and potential future members. React isn't complicated, you're making out to be.
- rnicholus 8y agoFirst off, this is not “the point of React”. Second, direct use of setState is not somehow the only path to focused DOM updates with React. In order to understand this better, I suggest you read up on the topic of Reconciliation in React - https://reactjs.org/docs/reconciliation.html https://reactjs.org/docs/reconciliation.html