News for hackers. Stuff that matters.

I'm about to give up on AngularJS, I'm going to try React

My implementation is pretty vanilla AngularJS with ui-router. All I want is for a user to use forward and back browser buttons to navigate. It doesn't work. I can't find a solution through searching Google. What few blog posts and StackOverflow questions I can find are from 2013 and 2014.

I'm not going to spend a week figuring out how all the internals work so I can roll my own solution.

If going to spend a week on something, it will be working with React. And, I'll see where that goes.

( 14 comments | 12 points | on HN )
Re:I'm about to give up on AngularJS, I'm going to try React by seanwilson on Thursday August 25, 2016 @06:06PM (#12362868)
> My implementation is pretty vanilla AngularJS with ui-router. All I want is for a user to use forward and back browser buttons to navigate

This really shouldn't be hard to get working. Try downloading a sample/example project that has routing set up already then strip it down to the bare minimum. Throwing a whole framework away because you're maybe missing a line of code somewhere isn't going to set a good trend.

Re:I'm about to give up on AngularJS, I'm going to try React by zappo2938 on Thursday August 25, 2016 @06:22PM (#12362958)
After several hours I figured it out. My biggest problem was that I had the same sentiment as your comment in "because you're maybe missing a line of code." I kept blaming myself when it was a bug in a popular module one of only a handful I'm using.
Re:I'm about to give up on AngularJS, I'm going to try React by seanwilson on Thursday August 25, 2016 @08:45PM (#12363563)
Just remember you're in good company! I find a lot of coding involves you trying to do something, getting an error, you look up the error, you try the solution you find, you get a new error and so on. Many people will give up after a few hurdles.

I tried to port an Angular 1 to Angular 2 recently and fixing issues to do with just getting the JavaScript modules/files to load drove me up the wall. I was close to giving up but after working through several layers of issues it eventually worked. Sounds like it was an similar experience to you...there's so many permutations of JavaScript stacks you can use that isolating the issue is like finding a needle in a haystack sometimes. What I mean is that sometimes all you can do it be persistent and realise that switching to a new framework could just introduce lots of new issues.

Re:I'm about to give up on AngularJS, I'm going to try React by niftich on Thursday August 25, 2016 @01:53PM (#12361013)
Though I enjoy React, React (by itself) isn't a full MVC framework like Angular.

Before you throw out everything, try this: https://docs.angularjs.org/guide/$location

Re:I'm about to give up on AngularJS, I'm going to try React by zappo2938 on Thursday August 25, 2016 @04:15PM (#12362125)
This is actually a helpful comment.

I've been working through $location and state change events. I've read and worked through every blog post and stack exchange question from the first three pages of the "angularjs $location" Google search results for the last 36 hours.

The browser address bar was flickering so I was wondering why that happened. It wasn't my code but I found the culprit.

Re:I'm about to give up on AngularJS, I'm going to try React by ry_ry on Thursday August 25, 2016 @03:23PM (#12361719)
React is a very nice UI view rendering lib, but that's pretty much all it does. Which isn't a bad thing at all, just something to bare in mind coming from Angular.

jsx is incredibly straightforward to read/write, and the actual time it takes to build anything is trivial, but if you drop a lot of es6 on it babel is going to output some moderately horrifying code when you dig into it.

Get your head around the component lifecycle stuff early and save yourself some O(n) heartache down the line.

Re:I'm about to give up on AngularJS, I'm going to try React by arisAlexis on Thursday August 25, 2016 @04:12PM (#12362100)
If you are going to spend a week in angular for routing you will spend a month in react cause react is a view rendering lib. Just read the docs and for for http://angular.io (angular2) they have a hands on example
Re:I'm about to give up on AngularJS, I'm going to try React by gordonzhu on Saturday August 27, 2016 @02:59AM (#12371341)
Did you try reading the ui-router docs?

https://github.com/angular-ui/ui-router/blob/master/README.m...

The "Nested States & Views" section of the README links to a full working demo on Plunker that does exactly what you want:

http://plnkr.co/edit/u18KQc?p=preview

Re:I'm about to give up on AngularJS, I'm going to try React by lastofus on Thursday August 25, 2016 @06:02PM (#12362842)
If all you really need is a router, you should probably just use a router:

https://github.com/AmpersandJS/ampersand-router

I've personally used this router with in a React SPA, though you can use it with pretty much anything including something simple like jQuery or Knockout. If you don't want to use a module loader, then grabbing the original Backbone router is probably your best bet.

Re:I'm about to give up on AngularJS, I'm going to try React by przeor on Monday August 29, 2016 @04:06AM (#12380657)
Good luck in React, there is a good learning material called "ReactJS Convention Book - ReactJS For Dummies: Why & How to Learn React Redux, the Right Way." - and it's 100% online at https://reactjs.co/
Re:I'm about to give up on AngularJS, I'm going to try React by calcsam on Thursday August 25, 2016 @01:46PM (#12360969)
Do it! React is way better.
Re:I'm about to give up on AngularJS, I'm going to try React by 1_listerine_pls on Thursday August 25, 2016 @09:18PM (#12363715)
?
Re:I'm about to give up on AngularJS, I'm going to try React by aprdm on Thursday August 25, 2016 @11:15PM (#12364056)
Vuejs is what you really want
Re:I'm about to give up on AngularJS, I'm going to try React by bwackwat on Friday August 26, 2016 @05:20PM (#12369395)
I personally recommend a vanilla front-end. Contact me for details.

^_^