react-oidc icon indicating copy to clipboard operation
react-oidc copied to clipboard

Feature: Custom Hook

Open chriskolenko opened this issue 6 years ago • 2 comments

While this is an easy way to get the "context"

<UserData.Consumer>{context => 
...
</UserData.Consumer>

A hook would make my code easier to read.

const UserProfile = () => {
    const context = useUser(); // better name needed

    return (....)
}

Thoughts?

chriskolenko avatar Aug 01 '19 22:08 chriskolenko

Totally agree that we should get some hooks going on!

thchia avatar Aug 02 '19 00:08 thchia

Sorry, forgot about this feature request.

I'll have sometime next week to send a PR. Looks like a one liner tho.

Example:

export const useStateValue = () => useContext(StateContext);

What do you think is a good name for the function?

chriskolenko avatar Aug 08 '19 01:08 chriskolenko