Comments (5)
Thanks for pointing this out. I really like the hook!
from auth0-spa-js.
My problem is related to passing the client down using React.Context.
Somehow the prototype is reset to Object.
Right after the promise resolves, the object does contain the methods.
from auth0-spa-js.
@nojaf did you have a fix for this? I'm following the documentation listed in the react quickstart and am applying it to my app. I'm still seeing this issue by using their example.
from auth0-spa-js.
So what I had is something like this
const App = ({auth}) => {
console.log(auth); // here prototype of Object
<p>my app</p>
}
createAuth0Client({}).then(auth0 =>
console.log(auth); // here prototype of AuthClient
const elem = document.getElementById("app")
ReactDOM.render(elem , <App auth={auth0} />);
)
My current workaround was
let auth0 = null;
const App = () => {
console.log(auth0); // still prototype of AuthClient
<p>my app</p>
}
createAuth0Client({}).then(auth =>
console.log(auth); // here prototype of AuthClient
auth0 = auth;
const elem = document.getElementById("app")
ReactDOM.render(elem , <App />);
)
I'm not a huge fan of this workaround. Because well a nasty mutable global.
from auth0-spa-js.
@nojaf I'm not sure if you've seen this, but we are trialling a React wrapper, which makes an appearance in out React SDK Quickstart. Eventually this wrapper will become a library of its own, but right now it provides an Auth0Provider
component that can wrap your application and provide the Auth0 instance, which uses Context under the hood.
You can see how the component is used on that same doc, or in the React auth0-spa-js sample app.
Does this help you with your issue? If you use the wrapper and have any feedback on it, we'd love to hear it.
from auth0-spa-js.
Related Issues (20)
- Make authorize URL configurable HOT 6
- "Misconfiguration in the system or a service outage" error in Auth0 HOT 3
- prompt in authorizationParams is not getting override. It is coming none even if it is set to other value like login. HOT 7
- Sophos Cyber Security Endpoint detects ransomware in the package HOT 3
- Total Cookie Protection breaks auth HOT 2
- Better error messaging when out of local storage quota? HOT 4
- Angular SSR window.crypto HOT 1
- User without Organization Membership caused infitine login redirect loop HOT 2
- NullInjectorError HOT 1
- Use '.well-known/openid-configuration' to configure Auth0Provider (Auth0Client) calls HOT 6
- Clarify limits for checkSession method HOT 7
- React Quickstart causing error upon clicking the login button HOT 2
- organization option of Auth0Client.getTokenSilently function is unexpectedly reuse previous value HOT 4
- Make getTokenSilently Generic HOT 2
- Support `getAccessTokenSilently` for multiple audiences in parallel HOT 1
- auth0-spa-js for multipage app? HOT 3
- Suport for multi tab sessions HOT 5
- Add configuration option for custom transaction storage
- LoginWithPopup doesn't work in Microsoft Word add-in on Mac HOT 3
- Extra redirect on silent login after upgrade to v2 HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auth0-spa-js.