OktaWidget with ReactJs code - Redirection Issue

I am trying to use the Okta Widget to authenticate and redirect the User to a new Website from ReactJs code but it stops after the Authentication and doesn’t proceed with redirection.

Followed steps as mentioned in Okta guide URL:
https://developer.okta.com/code/javascript/okta_sign-in_widget/

However I am able to achieve the same functionality following the steps from below url but it did not use the Okta Widget.
https://developer.okta.com/code/react/okta_react/

Error: Tokens values are getting as undefined in “OnSuccess” function
image

You might want to check out this sample app which uses a self-hosted widget with React.

This is not working in my scenario. I am able to open the Okta Widget and Login but the redirection part seems to failing.
In the below code ‘res.tokens’ value is not available and my response obj consists of ‘session and user’ details.

widget.renderEl(
{ el: widgetRef.current },
(res) => {
console.log(res);
oktaAuth.handleLoginRedirect(res.tokens);
},
(err) => {
throw err;
}
);