score:1

Accepted answer

the way to navigate within a react-router setup is by using the link component provided by the repo. your first suggestion to create an additional route for the additem component is correct. simply import the link component and define the expected path to go to.

import { link } from "react-router-dom

class inventorysystem extends react.component{
 constructor(props){
  super(props);
  this.state = {}
 }

 render(){
  return(
     <link to="/additem">add item</link>
  )
 }
}

you can style the link to look like a button if needed as it does accept a classname property.

score:0

you have 2 options, both included in example below

import { link } from "react-router-dom";

class inventorysystem extends react.component {
  constructor(props) {
    super(props);
    this.state = {}
  }

  goto(e) {
    // option 1
    this.props.history.push('/inventory/additem');
  }

  render() {
    return (
      <div>
        <button onclick={this.goto.bind(this)}>add item</button> // option 1
        <link to="/inventory/additem">add item</link> // option 2
      </div>
    )

  }
}

Related Query

More Query from same tag