Live data from Hacker News

Free React.js Fundamentals Course

courses.reactjsprogram.com

31–40 of 117 posts

Re: Free React.js Fundamentals Course

#31
post #12

Honest noob question, what's with all the hype about React? Edit: Awesome replies, thank you!

No one mentioned code sharing between server side and the client side! (There are other ways to achieve this other frameworks/libraries are catching up) If you have a node.js server you can use react for both server side rendering and client side rendering.. So that you get the SS rendering advantages like fast initial page load and SEO but also have a very dynamic web app after the initial render.

Have you built an app that does this? I'm interested in what the overhead is in setting it up vs. Ember's fast-boot.

Re: Free React.js Fundamentals Course

#32
post #30

Really can't decide to go ahead with an Angular approach (2.0) or use React. I know React is only for the view layer so what are people using with React to do stuff like api calls?

React seems to emphasize using regular javascript and existing NPM modules where possible. Superagent [1] seems to be a popular one, but you can find more on React's wiki [2].

If you start using a flux implementation like Redux, there are other interesting things you can do to handle api requests [3].

[1] https://github.com/visionmedia/superagent

[2] https://github.com/facebook/react/wiki/Complementary-Tools#d...

[3] http://redux.js.org/docs/advanced/index.html

Re: Free React.js Fundamentals Course

#33
post #30

Really can't decide to go ahead with an Angular approach (2.0) or use React. I know React is only for the view layer so what are people using with React to do stuff like api calls?

I've only just started using React but I've been a Django developer for a few years. As I'm starting to use React, I'm still working with Django and Django-Rest-Framework for my backend. It's probably a little heavy weight but you could use something like Flask or whatever equivalent light weight Web framework is in your language of choice.

Re: Free React.js Fundamentals Course

#34
post #33
post #30

Really can't decide to go ahead with an Angular approach (2.0) or use React. I know React is only for the view layer so what are people using with React to do stuff like api calls?

I've only just started using React but I've been a Django developer for a few years. As I'm starting to use React, I'm still working with Django and Django-Rest-Framework for my backend. It's probably a little heavy weight but you could use something like Flask or whatever equivalent light weight Web framework is in your language of choice.

I think he's asking what to use on the front-end. The author of these tutorials (at least from what I've watched so far) uses axios: https://github.com/mzabriskie/axios

Re: Free React.js Fundamentals Course

#36
post #30

Really can't decide to go ahead with an Angular approach (2.0) or use React. I know React is only for the view layer so what are people using with React to do stuff like api calls?

For API calls I use isomorphic-fetch[1]. To use it in redux I use redux-promise-middleware[2]

[1]: https://github.com/matthew-andrews/isomorphic-fetch

[2]: https://github.com/pburtchaell/redux-promise-middleware/blob...

Re: Free React.js Fundamentals Course

#37
post #30

Really can't decide to go ahead with an Angular approach (2.0) or use React. I know React is only for the view layer so what are people using with React to do stuff like api calls?

There's a touch more than views to consider, e.g. do you have to build or want a native mobile app? Angular 2.0 will be under heavy development whereas I think React has matured to the point where a lot of effort is going into ease of use and performance [1]. I also found the React tool chain (using webpack/babel5) very slightly more sane than grunt/gulp once my project grew beyond "Hello TODO". But the JS tooling is absolutely crazy no matter what platform is decided.

I'm using redux for API calls - I like the "single store" approach despite drawbacks vs. flux (or multiple stores).

[1] https://www.youtube.com/watch?v=-RJf2jYzs8A

Re: Free React.js Fundamentals Course

#39
post #34
post #33

Earlier quoted context omitted.

I've only just started using React but I've been a Django developer for a few years. As I'm starting to use React, I'm still working with Django and Django-Rest-Framework for my backend. It's probably a little heavy weight but you could use something like Flask or whatever equivalent light weight Web framework is in your language of choice.

I think he's asking what to use on the front-end. The author of these tutorials (at least from what I've watched so far) uses axios: https://github.com/mzabriskie/axios

Yeah I am. I have an RESTful API in js/express

Re: Free React.js Fundamentals Course

#40
post #30

Really can't decide to go ahead with an Angular approach (2.0) or use React. I know React is only for the view layer so what are people using with React to do stuff like api calls?

Here's a look at the folder structure we're using for our app: https://i.imgur.com/wc7DyOA.png

/actions: Flux action creators

/components: These are all the JSX React components (the presentation layer) - so there are subfolders like "pages", "controls", etc.

/reducers: These are Redux reducers - they're the logic that handles all of the application state

/services: This is what your question was really about. We use basic ES6 modules for services, with methods like "fetchUser(id)" which use the new JS Fetch API behind the scenes. We then have redux-thunk and redux-promise middleware so we can easily offload state manipulation to these services without actually putting state logic in them.

I've set up a few React projects at this point and this always seems to keep a nice separation of logic. I'm never asking where data is coming from or where it's going. I think Redux has been the biggest difference maker when dealing with all of these parts.

It's no framework, but it's composed of well understood libraries, each with their own important function. You build the structure out yourself so you know exactly how it works, and the pattern will be very familiar to anyone who has used React before.

Post reply on HN