I am trying to use my url as a parameter by passing the Match object into my react component class. However it is not working! What am I doing wrong here?
When I create my component as a JavaScript function it all works fine, but when I try to create my component as a JavaScript class it doesn't work.
Perhaps I am doing something wrong? How do I pass the Match object in to my class component and then use that to set my component's state?
My code:
import React, { Component } from 'react';
import axios from 'axios';
import PropTypes from 'prop-types';
class InstructorProfile extends Component {  
  constructor(props, {match}) {
    super(props, {match});
    this.state = {
        instructors: [],
        instructorID : match.params.instructorID
    };
  }
   componentDidMount(){
      axios.get(`/instructors`)
      .then(response => {
        this.setState({
          instructors: response.data
        });
      })
      .catch(error => {
        console.log('Error fetching and parsing data', error);
      });
    }
  render(){
    return (
      <div className="instructor-grid">
        <div className="instructor-wrapper">
       hi
        </div>
      </div>
    );
  }
}
export default InstructorProfile;
 
     
     
     
     
     
     
    