1

Is possible to do something like this:

<Route exact path="/activate/:token" render={this.activateAccount} />

then in same component

activateAccount(token) {
    console.log(token);
    return null;
}

How to pass token?

Is my logic correct? Learning MERN a bit, what I find confusing right now is how to move between backend and frontend, for example here when I generate activate account URL I have something like

http://localhost:5006/api/activate/8d7f5b25befb70045b5cb36893fa0f7688b85504

Now my NodeJS/Express is running on 5006 port and my ReactJS is on 3006, not sure what is logic here, I can finish everything on my NodeJS side in this case but not sure how to redirect later on to /login/ on frontend.

Thanks!

1 Answer 1

1

The parameter of activateAccount won't be token:

<Route exact path="/activate/:token" render={this.activateAccount} />

As the reference states, Route render function receives route props:

All three render methods will be passed the same three route props

  • match
  • location
  • history

Otherwise it wouldn't be impossible to make use of them in route component.

It is:

activateAccount(props) {
    console.log(props.match.token);
    return null;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for point in right direction! This worked just fine, activateAccount({ match }) { console.log(match.params.token); return null;}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.