Unable to get data on Other Route using REDUX & ROUTER - reactjs

I'm building up a website using ReactJS, REdux,React-Router.I want to access the data upon a different Route i.e for search functionality but I'm unable to do so. I'm only able to access data upon same page.
My App Component
Home Component
I'm dispatching the Action from SearchComponent to store.
I want to access data on /Search Route but unable to do so.

You should point to the component in route element.
Add the component attribute to the route element, pointing towards the component that it should use when hitting the search route.
Remember to import the component first.

Related

React Router - History

I have a react app with multiple routes. On one of my routes I only want to render a certain component if the user navigated from a specific route. How do I check the previous path used to get to the current route? Thanks

In React, how do you properly programmatically navigate to a new route/page?

I've been trying to find a straight answer to this and even after searching StackOverflow, I can't find a correct answer for the current version of React.
In my case, I have the following scenario-- the user sets up their data, they post it to the server and within my Save() method, if the save operation is successful, I want to redirect them to the root home page.
Much of the documentation I've found mentions using this.props.history.push(...) to push the new route. However, something has changed with React 4.0.0+ and now history is undefined on the props page.
I am not necessarily interested in pushing the new route to the history object if that is a deprecated way of routing to another page. However, all of the more current examples I've found talk about setting up routes and links within the JSX. That's fine, but I've yet to find a way to programmatically redirect the page un certain code conditions.
Apologies if there is an answer out this already, but I haven't found a straight answer.
The route props are only given to the components that are used for the component or render props of the Route components.
If you want to use the route props in any other component in your app, you need to pass the props manually or use the withRouter HOC.
import { withRouter } from "react-router-dom";
// ...
export default withRouter(MyComponent);
You have to connect this component with router. To connect you have to use withRouter.
export default withStyles(commonModalStyle)(withRouter(connect(mapStateToProps, mapDispatchToProps)(NewOrUpdateModal)));
Please refer this

Xamarin reactjs webview navigation

I'm trying to detect when the page location changes in a react app using the Xamarin forms webview .Navigated event. However, it seems like it's only issued when I navigate to an external page, not within the react app, even though I'm using react router. In my browser, the url changes but the Xamarin webview doesn't register that change, even if I manually poll the url by printing webView.Source.
Is there some way I can detect a navigation within the react app from C#?
If you want a component to be location aware, you can wrap it with the HoC withRouter provided by React Router.
You can get access to the history object’s properties and the closest <Route>'s match via the withRouter higher-order component. withRouter will re-render its component every time the route changes with the same props as render props: { match, location, history }.
Once you're getting location change updates in your react app you can update your C# to perform any actions you require.
EDIT: To address your comment...
Now I've never used C#, but according to my research this should work.... take a look at __doPostBack. You can read about how to use it here.

What is the different between Router vs Route in react-router-dom

In the React-Router documentation I have seen that It has import both Route and Router modules from react-router-dom. I would like to know what is the different between those two modules?
Router
Router component is what makes the connection between browser location and the react application. It doesn't render anything visible on your page. It just exposes API to interact with location changes of the browser via React context. So any component down the tree can use this API to change their behavior based on location changes in the browser or change the browser location into what they want.
Router is the abstract for all other specific router components. Practically, we use a specific implementation of it like BrowserRouter, MemoryRouter, and HashRouter which use different methods to manage browser history. Also, Router is usually a top-level component in the component tree and use only one time in the entire application. All other react-router components should be descendants of Router as they can't function without the API which Router provides.
Route
Route is much simple to explain. It just renders some UI when a location matches the route’s path. So an application can have many Routes based on its layout complexity in different levels of the component tree. Also, Route has some additional props to configure how the match should happen. Route internally use API provided by Router to access the location and decide whether to render the given component or not.

React router get current route outside component

I am now using fluxible with react-router, I want to perform action and then redirect after the callback.
In the action, the action context has no router and fail to change the route after the action.
I have tried to find example but I can only found using browserHistory.
I can now push the browserHistory but somehow I can't find the current path. (because my new path is the depends on the current path /:id/profile, and then I want to redirect to /:id/details/:version), So I need to get back /:id/details before I append the version).
How to find the current route in the action where I can only access the action context without router instance?
Sometimes my react router works on server side but not client side. It will show when I refresh the page but 404 when in client side only.( I guess because I am using the relative link)
Does react router support relative link in the ?
How to pass the params and router in the stateless component?
In the stateless component, I can only access props but not context. So I can't access the router or params?
I want to make use of the params and link with an absolute path with id.
Thanks
For the Question 3, I have figured out the method to access the params
In fact, the second argument in the stateless component is context. I have pass the params and obtain there.
e.g
const CompanyDetail = (props, context) => {
}
CompanyDetail.contextTypes = {
params: PropTypes.object,
};

Resources