I'am new to React and during my "self-learning" process I discovered Redux. Nice! Then, React-router-v4. Nice too!!
Then, I discovered how to mix redux and react-router-v4, a little bit tricky, but it works.
Last week, I also discovered mobx and I love it. I like its simplicity compared to redux. But I wonder if somebody is using it with react-router-v4 because I did not find much tutorials on the web that talk about this mix of technologies.
Any feedback or advice?
Thank you guys!
Related
I am doing a tutorial on React with Redux and Thunk and am having trouble understanding how some of the props are being sent to the different components. I think I understanding how the Flux Architecture in general is working, but the code itself filled with functions returning other functions and other syntax that is making my head spin. How the dispatcher is working for example is a complete mystery to me. Googling around I have read that this is a very "functional programming" approach to doing things in react. Can anyone point me to some resources to get up to speed with the type of Javascript used for Redux and Thunk?
Thanks!
Here are some links,
Redux.org
React-redux tutorial for beginners
Redux-thunk
I am new with react js.
I made two components to send/receive data using props between them.
But it gets more complex, I feel like I need to replace them with other solution like redux. I wonder there is the latest better solution to replace redux now for communication between two react components.
There was a lot of opinions between redux and context api like this post. But today, I can say yes, you can replace redux with just react itself. Because, currently react provides so much concepts just like the redux, context api. You can find react additional hooks like useReducer, useCallback, useMemo, etc.
But arguably, redux is still worth for maintaining project easily. You can have redux devtool, keep the code clean (state in store - a separate place for concerns).
There are more concerns over this. You may see this issue what future react will have. You may also find the medium blog helpful and the reddit discussion.
Worth Reading:
State management with react hooks and context api
Redux main task is to be a 'predictable state container', and, as you wrote, it also makes sharing data between components much easier. The main drawback is that it requires additional code, but I think that it is worth it.
For apps / websites that are not very small, I wouldn't use react / react native without it.
The way redux works may be a bit difficult to understand in the beginning. The following is a great article that helped me when I started using it: redux connect explained
I've spent the past few days looking at VueJs 2 with Vuex and i really like it.
Having only had a brief introduction to React, I've found vue js 2 has been easier to pick up.
React seems to be growing in popularity, but I can't see the benefits of React over Vue 2.
Both are component based frameworks with routing and state management tools.
So can someone explain which are the main differences between those frameworks?
This is an opinionated and subjective question. And it often starts holy-wars than really answering anything and thus it is not really suitable for StackOverflow. However, I will try to answer this in an objective manner as possible. (Note: I am purely comparing Vue with React and deliberately avoiding Vuex vs Redux)
Why Vue.js?
It is designed to be an approachable framework. It is suitable for beginners and advanced users alike. When you are starting with Vue.js, it is as simple as adding a script tag to your page. For the advanced developer, the possibilities are endless. You can start with any sophisticated build tools - TypeScript, Babel, Webpack, etc.
Vue.js is developed much after Angular and React. It has learned from both and managed to pick many best things from them into Vue. For a beginner, Angular's idea of components, services, dependency injection, bootstrapping application, etc can feel overwhelming. Same is applicable to React; JSX can feel odd (Even after years, I still find it weird.). Now, Vue.js is a cross-path. You can use angular like templates or you have the freedom to choose React like JSX.
Vue.js reactivity is very well abstracted. With Angular (digest cycle in v1 and zones in v2) or React, it is bit different. It takes time to learn these concepts.
There are tons of other reasons why Vue.js should be your choice. Sometime back, I had written an article explaining why Vue.js:
https://blog.webf.zone/vue-js-answering-the-why-after-15-months-62db797f75cc
Why React?
React is a pioneering library (It is not a framework) just like Angular. It introduced the ideas of uni-directional architecture, virtual-dom, components (stateful and stateless), etc.
React Native is another reason why you may want to consider React. It allows you to take the same code that you wrote for Web and build native mobile applications. Now solutions do exist in the Vue.js world. But definitely not as mature as React Native.
Functional programming: No way React is a library based on functional programming. But doing React right way means you need to use immutability, explicit state management and all these allied concepts stemming from functional world.
Redux: Redux is the darling of React world. It has unlocked wonderful architectural patterns for front-end world like time-travel debugging, explicit side-effects, functional components, etc.
Innovation: React has some crazy ideas like Relay, Next.js (Vue.js has Nuxt.js). I also heard about some Drap-n-drop editor for React; first class TypeScript and Flow support (You just cannot get TypeScript + Vue.js + JSX working together even in 2018).
Why not React?
Using only React is not enough. Very soon, you will end up with using Redux, Redux middleware, Immutable.js, etc. Doing all of that at once can be intimidating.
Redux. It is wonderful but it is verbose.
Most important: Using React without any sophisticated build system is cumbersome. To do anything serious, you will need Babel, Webpack, etc.
Again, which one is better?
There is no better solution. I will choose Vue.js if I need to accommodate a vast array of developers (beginners-advanced). I will choose React if my team is versed with all the extra overload that comes with React and team loves everything JavaScript approach to web development (Even CSS is JS).
Finally, there is one another angle to it. Programming in React needs discipline and hence, there is a good chance that you will find it easier to bring homogeneity to your codebase. With Vue.js, there is often more than one solution to a problem. That makes it good and bad at the same time.
You will not go wrong with either of them.
I'm new to react and while browsing through the net I came across various terms associated with React - Flux, Redux, Relay, Graph QL.
So far I understand these are design patterns for a React app.
I want to embark on a small side project using react and am confused as to which architecture to invest time and effort in learning and implementing .
Could someone please help me out here ? Thanks!
A brief overview of each with the pros and cons would be ideal .
Yeah, it can be daunting. The thing is React is just a UI component framework (but an awesome one) so the rest of the application architecture is up to you. Flux and Redux are solutions to managing state (not just in React), both are certainly worth learning about. Relay and GraphQL from Facebook are solutions to fetching data from a server and requires both client-side and server-side implementations to be used.
I agree with Tom's comment: for a small project start with just React (and complimentary libraries for details like AJAX and routing). There are still basic React patterns to get the hang off. Once you are comfortable with React and your app gets large enough, you will likely start to feel the strain of managing state in your UI, and that will be a good time to seek out something like Flux or Redux.
I have been playing with ReactiveX for a bit and really like the approach. I have also been following Relay and Falcor for a while and understand the advantages of declarative data fetching.
I have seen people integrating react, redux with falcor, but have not seen any attempts to integrate React, Rxjs with either Relay or Falcor.
So I wanted to write a simple todo example, but before that wanted to ask whether it is a sound combination at all. Are there compatible and whether some advantages of one approach will negatively affect advantages of others.
Also if anyone can share some resources on this topic please do :)
There are several libraries that I found:
https://github.com/trxcllnt/reaxtor no React js though
https://github.com/FourSS/refar
UPDATE: there is an attempt by meteor developers to create their own version of relay using reactive graphql see Apollo Project They use observables for watch queries
Also there is a good library called relate which you can integrate with rxjs redux style state machine