-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SDK-1580] [SDK-1581] Add withAuth and withLoginRequired #7
Conversation
@@ -28,7 +28,7 @@ Auth0 SDK for React Applications. | |||
## Installation | |||
|
|||
```bash | |||
npm install react react-dom @auth0/auth0-spa-js auth0/auth0-react | |||
npm install @auth0/auth0-spa-js auth0/auth0-react |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we didn't really need to tell users to install react
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could removing this though lead to the assumption that we install react for them as a dependency? How would they know that without diving into package.json
?
Perhaps we don't need to include it in the installation command but we could cover that with a quick sentence prior to this which says something to the effect of "This SDK should be installed into a React application". The clue is in the name. However, I think we should be clear.
@@ -20,7 +20,6 @@ | |||
"types": "dist/index.d.ts", | |||
"module": "dist/auth0-react.esm.js", | |||
"scripts": { | |||
"prepare": "rollup -c --environment NODE_ENV:production", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work with react because of facebook/react#14257
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of things to think about which I don't want to hold up the EA release, but could be talked about before we head to beta.
@@ -28,7 +28,7 @@ Auth0 SDK for React Applications. | |||
## Installation | |||
|
|||
```bash | |||
npm install react react-dom @auth0/auth0-spa-js auth0/auth0-react | |||
npm install @auth0/auth0-spa-js auth0/auth0-react |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could removing this though lead to the assumption that we install react for them as a dependency? How would they know that without diving into package.json
?
Perhaps we don't need to include it in the installation command but we could cover that with a quick sentence prior to this which says something to the effect of "This SDK should be installed into a React application". The clue is in the name. However, I think we should be clear.
* Get an access token. | ||
*/ | ||
getToken: ( | ||
options?: GetTokenSilentlyOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're surfacing options types from SPA JS here are we still able to generate documentation as if they were part of this library?
Surfacing these options couples us tighter to the underlying SDK, which should be somewhat transparent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I think we'd need to bundle a version of spa js with the library if we don't do this (which we could do?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth a further discussion but all I'm talking about really is wrapping those SDK types with types native to the React library rather than exposing GetTokenSilentlyOptions
.
We would just have GetTokenOptions
for example, which internally maps to GetTokenSilentlyOptions
. Means the SDK isn't as exposed but also we can generate the right doctypes and not force the user to go elsewhere to figure out what properties they can specify and what their docs are.
Description
Adds higher order components:
withAuth
for wrapping class componentswithLoginRequired
for protecting components (usually routes)Testing
Checklist
master