best approach to navigate pages in react js - reactjs

Hope you are doing well!
I found different ways of navigation in React Js.
For example
Using Link, NavLink, Redirect Component, history.push and history.replace.
I am a bit confused, which method is perfect or recommended. Thanks.

I'm new to React as well and I think using any sort of Link/Navlink along with the Switch Route is a good way. It helps me sort of modularize the routing, no matter where the path changes from.

As a new learner, you only need to know <Route>, <Switch>, and <Link>. And also <Link> and <a> difference. The rest you mentioned comes with intermediate level React. So, I kindly advise you to take it bit by bit and also try to make your questions more to the point as editor noted in comment.

Related

Antd, ReactJs, Routing and Component rendering issue

I have an issue with a project I'm working on.
I tried to implement "dynamic" routing and rendering of components, but it seems to just not work.
I have added a sandbox link containing some of the routes and basic components along with the structure I was going for.
It seems as if I hard code the routes and components to render, everything works, but when I use the component that accepts the component, it won't render. I am not sure why.
I would appreciate any help or insight anyone is willing to give.
Edit on sandbox

Not able to route in reactjs

I am not getting how to link different pages in react js. I'm using react router through which by using link and route tags I'm able to change the url but not getting the content.
Can I get the answer as soon as possible..
Can you provide your code snippet?
There might be several reasons, maybe check the router nested settings, and see if it setup correct.

Any cleaner way to trigger React Route change?

I am pretty new to React-Router, I wonder if there is a simple way to change Route, some concept like state in Angular UI Router. From the React Router official tutorial :
https://github.com/reactjs/react-router-tutorial/tree/master/lessons/12-navigating
My understanding is: I have to manually change the url to trigger route change.
What exactly are you trying to achieve? Did you take at look at the react-router Link component?
Perhaps the most used component in your app is Link. Its almost identical to the <a/> tag you're used to except that its aware of the Router it was rendered in.
React-Router Tutorial / Lesson 3: Navigating with Link

React Native - Navigation between different views

I just approached to react native/react and are a bit confused...I specify that I have a background with angularjs, cordova, ect...Now I have a problem...I'm reading Flux and I want to use it in my application because it improve the structure with the unidirectional data flow.
The most important decision is the navigation in my app, so in the documentation of native react I found the component "Navigator". Now I don't understand if I can use the Navigator and Flux together or one excludes the other.
if you have informations, advices or examples, it's welcome. Thanks.
Infact you can use combination of both. Here is one library that and provides a router API on top of Navigator. https://github.com/aksonov/react-native-router-flux
You can use RN Navigator and Flux together, they're not excluding each other. Here is few navigation articles, that might help you:
http://blog.paracode.com/2016/01/05/routing-and-navigation-in-react-native/
http://tech.taskrabbit.com/blog/2015/09/21/react-native-example-app/
https://medium.com/the-exponent-log/routing-and-navigation-in-react-native-6b27bee39603#.ae10t4lks
You can find they're all stating that you can use Flux actions to dispatch events, update navigation bar buttons and screens content etc.
I'm not using Flux, but on your place I would try to read react-native-router-flux code, read articles and try to buid flux-navigator myself with all that aknowledged ^^. Good luck, I hope this will help you :)

migrate to redux from a structure like react-router huge apps example

I implemented dynamic routing following react-router huge apps example. now i want to use redux for easy state management but have no idea how to go from here.
the file directories are all nested with different routes and the code is separated to 7 chunks. is there any example or guide on how to migrate to redux from huge apps example that react-router gives?
Thanks.
You are looking for Redux-simple-Router. The idea is to store your router state in the redux store.
react-router does a great job of mapping the current URL to a component tree, and continually does so with any URL changes. This is very useful, but we really want to store this state in redux as well.
There is another package Redux-router. Which is also worth a look, but redux-simple-router does the job easily.
redux-router is another project which solves the same problem. However, it's far more complex. Take a quick look at the code for this library—it's extremely minimal. redux-router is much bigger and more complex.

Resources