Hey guys, my first post here. I’m building a small asignment with React + Meteor and i run into a problem: tags change the url, but the components dont change. Only after i refresh the webapp the component changes. I want to have a sidebar all of the time and render the other component depending on the URL WITHOUT REFRESHING THE PAGE.
here are the components:
import React from ‘react’;
import Sidebar from ‘./Sidebar’;
import { BrowserRouter, Switch, Route } from ‘react-router-dom’;
import CustomersComponent from ‘./panel-parts/Customers’;
import OrdersComponent from ‘./panel-parts/Orders’;
import ProductsComponent from ‘./panel-parts/Products’;
class App extends React.Component{
render(){
return(
);
};
};
export default App;
AND
import React from ‘react’;
import { BrowserRouter, Link } from ‘react-router-dom’;
class Sidebar extends React.Component{
render(){
return(
Andrius Avlas
<Link to="/products" onClick={()=>history.push(’/products’)}>Products
<Link to="/orders" onClick={()=>history.push(’/orders’)}>Orders
<Link to="/customers" onClick={()=>history.push(’/customers’)}>Customers
);
};
};
export default Sidebar;
Thank you for your answers in advance.