react router dom props typescript code example

Example 1: how to install react router dom with typescript

npm install react-router-dom @types/react-router-dom

# Yarn
yarn add react-router-dom @types/react-router-dom

Example 2: react typescript props

// Declare the type of the props
type CarProps = {
  name: string;
  brand: string;
  price;
}

// usage 1
const Car: React.FC<CarProps> = (props) => {
  const { name, brand, price } = props;
  // some logic
}

// usage 2
const Car: React.FC<CarProps> = ({ name, brand, price }) => {
	// some logic
}