samples-js-react icon indicating copy to clipboard operation
samples-js-react copied to clipboard

Remove `authState.isPending`

Open mraible opened this issue 4 years ago • 5 comments

Question: is it possible to do !authState?.isAuthenticated instead of !authState && !authState.isAuthenticated?

mraible avatar Jun 28 '21 15:06 mraible

It looks like this file needs to be fixed too.

mraible avatar Jun 28 '21 15:06 mraible

Thanks for submitting this PR. Yes, isPending is obsolete and should be removed.

Code !authState.isPending && should be removed completely, no need to change it to !authState because there are lines before that make this check:

https://github.com/okta/samples-js-react/blob/6702f999e7f5372db9b1c4c6e108b84d96e03499/okta-hosted-login/src/Navbar.jsx#L38-L40

Same for this file

denysoblohin-okta avatar Jun 29 '21 15:06 denysoblohin-okta

@denysoblohin-okta How should I change this line? If I remove the conditionals, will a login button still be rendered?

{!authState.isPending && !authState.isAuthenticated && <Menu.Item onClick={login}>Login</Menu.Item>}

mraible avatar Jun 30 '21 17:06 mraible

@mraible where did you see the issues with the code snippet above? this sample repo or other apps? As optional chaining is a part of ES2020, you may need to config the transpiler to make it work.

shuowu avatar Jul 14 '21 13:07 shuowu

@shuowu It worked for OktaDev Schematics, which generates an app with the latest version of Create React App. https://github.com/oktadev/schematics/pull/636/commits/2c90198adeba5afc326aae6d7029b6530cea9e97

mraible avatar Aug 03 '21 01:08 mraible