score:0

      constructor(props) {
          super(props);
          this.componentLogic = this.componentLogic.bind(this);
      }

      componentLogic() {
        // fetch something or some other business logic
      }
    
      componentDidMount() {
        this.componentLogic();
      }
    
      componentDidUpdate(prevProps) {
        // Typical usage (don't forget to compare props):
        if (
          this.props.reactRouterDom.params.slug !==
          prevProps.reactRouterDom.params.slug
        ) {
          this.componentLogic();
        }
      }   

score:1

someFunction = (passedVar) => {
    // do something with passedVar, which you'll pass from the new component
}

// ... then in the Router...

<Route path="/some-route" render={(props) => <NewComponent ...props onRouteLoaded={this.someFunction} />}} />

Related Query

More Query from same tag