My man, a lot of the pain described in this article can be solved by Mobx: https://stackshare.io/mobx One of our engineers at StackShare[0] suggested it and it's fantastic. Mobx is very simple to understand and will make writing a "React" page a real joy again. Redux was way too complicated for what it gave, and just shot term after term after term at me that left me with a headache. I still don't understand Redux pr…
Why we chose Vue.js over React
201–210 of 267 posts
Re: Why we chose Vue.js over React
#202Earlier quoted context omitted.
> And finally, what stops you from creating a custom component that works like this? I wondered what the issue was myself, so I actually implemented that pattern in a codepen, then looked at the compiled form of the JSX to Javascript. The essential issue is that the value of a prop is always evaluated at runtime, regardless of if the prop is actually used. In the case of props.children this means that and are both ev…
Wrapping them in methods is an easy way to fix that... but not sure if it is any cleaner. render() { return `Hello ${ this.state.userName }`} else={() => `Please log in` } /> }
{this.state.user.case({
some: user => `Hello ${ user.name }`
none: () => `Please log in`
})}
Or for async requests that are in progress, an algebraic 3-state type:Re: Why we chose Vue.js over React
#203The arguments against JSX and React requiring many small components are very surface level and sound like "we couldn't figure out how to make it work for us so it must be impossible". 1. This was mentioned already, but, yes, you can use ternaries and boolean logic for simple conditionals (loggedIn && Logout || Login ) 2. When you need more markup, put them in an if-else statement in the same render function. render()…
> And finally, what stops you from creating a custom component that works like this? I wondered what the issue was myself, so I actually implemented that pattern in a codepen, then looked at the compiled form of the JSX to Javascript. The essential issue is that the value of a prop is always evaluated at runtime, regardless of if the prop is actually used. In the case of props.children this means that and are both ev…
https://www.npmjs.com/package/jsx-control-statements
Disclosure: self-promotion. It's really frustrating that I see this React-is-crap-because-no-conditionals come up again and again but if you want them all it takes is an npm install and a line of babel config :(.
Re: Why we chose Vue.js over React
#204Almost every Redux example is tons of repetitive code because of this, and that's before you add in middleware, thunk, saga, reselect etc. Yes I know Dan himself wrote a bunch of articles on how you don't really need to use it and how its conceptually simple, none of that changes what most of the libs and code looks like.
I don't have the answer but I can't help but think there has to be a better way to handle this. We had templates and generics decades ago exactly to reduce repetitive boilerplate.
Redux should never have been adopted in its current form. Its exactly the sort of thing that should be handled by a framework/tooling for you. Imagine if for every React component you had to write a custom parser/resolver/reconciler, all of which had 99% common code and just passed params around. That's what redux boils down to.
Re: Why we chose Vue.js over React
#205The arguments against JSX and React requiring many small components are very surface level and sound like "we couldn't figure out how to make it work for us so it must be impossible". 1. This was mentioned already, but, yes, you can use ternaries and boolean logic for simple conditionals (loggedIn && Logout || Login ) 2. When you need more markup, put them in an if-else statement in the same render function. render()…
Thank you for fixing the misleading information from this article. I would add: 1."now you have to create 10 functions to get input from 10 inputs". Or you can learn JavaScript: handleChange(event) { this.setState({ [event.target.name]: event.target.value }) } 2. "Redux sounds like a synonym of verbosity, as well." Nobody forces you to use Redux. https://medium.com/@dan_abramov/you-might-not-need-redux-be4...
Dumb question but I've never seen this syntax before. What does it do or what is it called? (The brackets)
Re: Why we chose Vue.js over React
#206Earlier quoted context omitted.
Basically React seemed immature, as if it wasn't thought out fully but just hacked together. Vuejs seems like what React could've been if it was thought out a Bit more. It just feels a lot more polished. Honestly I think Vue is so far ahead of the curve it isn't a surprise to see more people switch away from React.
I wouldn’t say React is “hacked together”. Perhaps you are referring to the React ecosystem? Facebook doesn’t build single-page apps with React, so naturally it doesn’t provide solutions for routing and similar concerns, so there is more churn as people are figuring this out together.
Re: Why we chose Vue.js over React
#207Earlier quoted context omitted.
I wouldn’t say React is “hacked together”. Perhaps you are referring to the React ecosystem? Facebook doesn’t build single-page apps with React, so naturally it doesn’t provide solutions for routing and similar concerns, so there is more churn as people are figuring this out together.
Wait, do people use React for non-SPA websites?
Re: Why we chose Vue.js over React
#208Earlier quoted context omitted.
Thank you for fixing the misleading information from this article. I would add: 1."now you have to create 10 functions to get input from 10 inputs". Or you can learn JavaScript: handleChange(event) { this.setState({ [event.target.name]: event.target.value }) } 2. "Redux sounds like a synonym of verbosity, as well." Nobody forces you to use Redux. https://medium.com/@dan_abramov/you-might-not-need-redux-be4...
> [event.target.name]: event.target.value Dumb question but I've never seen this syntax before. What does it do or what is it called? (The brackets)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re: Why we chose Vue.js over React
#209Earlier quoted context omitted.
No one gets fired for using React. Vue isn't even shinier in my opinion. It makes the same templating mistakes that Angular and Backbone did.
What are those mistakes? I don't do front-end development so my knowledge is very limited with these (I know the names and a basic idea what they do)
Re: Why we chose Vue.js over React
#210The arguments against JSX and React requiring many small components are very surface level and sound like "we couldn't figure out how to make it work for us so it must be impossible". 1. This was mentioned already, but, yes, you can use ternaries and boolean logic for simple conditionals (loggedIn && Logout || Login ) 2. When you need more markup, put them in an if-else statement in the same render function. render()…
Wow. Do people consider this kind of coding acceptable now? We spent decades trying to separate templates, business logic, and inlined JS, and you managed to cram all three into a short snippet.