13 ms·
I like the opinionated approach of NG2 over the flexibility of React because it takes a lot of decisions off of me that i am not too interested in when building
by kayoone 10y ago
I like the opinionated approach of NG2 over the flexibility of React because it takes a lot of decisions off of me that i am not too interested in when building a new project. I am a full stack developer leaning more towards backend in recent years and i found setting up and finding out about best practices and "what to use" for React a bit tedious, also it changes so much. The last Flux framework i used was alt.js which was popular last year but is hardly used anymore.
I also really like Typescript and believe enforcing it is a good way to get general JS code quality up.
- danmaz74 10y agoRegarding the "Flux" frameworks, that's not a problem anymore - basically Redux (which improves on some of Flux's faults) has won. Its developer was hired by Facebook, so I guess it's kind of officially sanctioned now.
- subsection1h 10y agoHas everyone who switched from Redux to MobX been informed that Redux won and they should switch back?
- k__ 10y agoI didn't understand this. Isn't MobX the "classical" way of databinding everybody frowned upon for years? And now that React finally eased that pain with Flux and then Redux, they bring it back?
- boubiyeah 10y agoI don't think that many people switched to MobX to be honest. It's very similar to knockout observable and while it works, I don't think I would use that approach again. I suspect people like the familiar OO syntax of MobX. I can't think of advantages it has over plain old streams (most.js, flyd.js)
- Kiro 10y agoWho has switched? Do you have any example?
- simonrobb 10y agoI've just finished my first major redux project and found it incredibly slow to develop with. Write an action type constant/action creator/dispatch/reducer/mapStateToProps just to show an element in response to a mouse click? I found myself cutting corners on the UI because the amount of code I'd have to write makes it seem like a huge task. I'll be evaluating mobx for my next project, definitely, along with Relay. If I can maintain the same view-as-a-function-of-state approach of redux while writing less code, I'm sold.
- Kiro 10y agoThat's interesting. I've only used redux for one project and you may be right. It is tedious to all those things for every little action.
- danmaz74 10y agoI'll admit that I hadn't heard so much about MobX yet. Will re-evaluate when I have time.
- awjr 10y agoOf note, Facebook's create-react-app provides an "official' opinionated approach. https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html https://facebook.github.io/react/blog/2016/07/22/create-apps... There's even a pull request to bring typescript into the mix. https://github.com/facebookincubator/create-react-app/pull/509 https://github.com/facebookincubator/create-react-app/pull/5...
- Brakenshire 10y agoI'm just writing a first React app, and read beforehand that it was going to be difficult to choose which libraries to use, and to get them to work together, but I haven't found that to be much of an issue in practice. create-react-app set up all the build tooling, for a router the clear recommendation is react router, and for a flux implementation the clear recommendation is Redux. It feels like there's a well defined path for beginners. Over time you'll have to figure out how everything works, as is always the case, but you can learn more as and when it's necessary. The bumps were more whether to use ES5 or ES6 (but then I found an official position in favour of ES6), and whether or not you need to use flux (although that was really just learning how flux worked, which wasn't wasted time). The only uncertainty I have now is whether TypeScript will be necessary/useful in future, and if so how to integrate it.
- awjr 10y agoHaving used TypeScript and also picked up recent projects where it is not being used, TS is definitely the way to go. The issue is that TS 1.8 doesn't support async/await in the browser until v2.0, but a ts -> babel transpile does the job nicely.
- boubiyeah 10y agoYou can totally use typescript with React, in fact it's a game changer. It's actually way more beneficial than with angular, as you have properly typed components all the way down. No crappy string templates that are not checked by typescript.
- k__ 10y agoTrue story. But how did you get rid of the implicit anys when using JSX? I used this compiler flag that forbids them and suddnendly nothing worked anymore. It seemed that almost everything returned any per default.
- boubiyeah 10y agoThat compiler flag is wonderful, and so is the newer 'strictNullChecks' I use these typings: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/react/react.d.ts https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast... Then create my components like this: interface Props { } interface State { } class MyComponent extends React.Component<Props, State> { } and everything is typed correctly (beside setState which is impossible to type exactly as of today)
- k__ 10y agoMaybe it was the type definition I used...
- boubiyeah 10y agoStateless component: interface Props { bla: string ble: number } export default function MyComponent({ bla, ble }: Props) { }
- woah 10y agoHow would you do something like this with stateless components? (Where the component is just a function that takes props)
- davedx 10y agoYup, this is a major strength of the front end frameworks. It can't be understated in my opinion. I work daily on a large Angular app and a growing React app, and my React app, while being more pleasant to work with, is also much harder to keep standardised and clean. I'm also already experiencing perf issues because of not using immutableJS, which is quite annoying...