Giter Site home page Giter Site logo

Comments (5)

nojaf avatar nojaf commented on July 16, 2024 1

Thanks for pointing this out. I really like the hook!

from auth0-spa-js.

nojaf avatar nojaf commented on July 16, 2024

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.

blakedietz avatar blakedietz commented on July 16, 2024

@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.

nojaf avatar nojaf commented on July 16, 2024

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.

stevehobbsdev avatar stevehobbsdev commented on July 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.