question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default customisable components to render nothing [requires api change - thoughts?]

See original GitHub issue

Hey 😃

So I’ve got an initial setup that looks like this:

  <AuthenticationProvider
    configuration={oidcConfiguration}
    loggerLevel={oidcLog.DEBUG}
    notAuthenticated={() => null}
    notAuthorized={() => null}
    authenticating={() => null}
  >

I’d also like to have a null component returned for the callback component, as outlinded in this issue: https://github.com/AxaGuilDEv/react-oidc/issues/181, but until that issue is resolved this is not yet possible.

While trying to test this on my consuming application, I am currently looking at mocking out the <AuthenticationProvider> at the unit test level, and having a mock for withOidcSecure() which proves this function is called when rendering protected routes.

I am planning to properly test the oidc logic using an integration test that uses something like testcafe. This will login to our identity provider and prove the logic works properly.

However, the unit tests have code coverage running on them, and the lines exposed by the above props that are returning null will be uncovered by the unit tests using this setup.

While thinking about this problem, I thought it might make sense to ask you to consider changing this api so that these components all render nothing unless explicitly passed in a React component. This behaviour would still allow for any custom component to be rendered, but would by default display nothing to the end user, it would just redirect them.

If you are happy to make this change (I appreciate this is a breaking API change so may require a major version release), I’d be happy to pick up this work and make the required changes myself. I don’t want to do this if you don’t agree with the idea though.

Can you please let me know what you think, and if you like this idea I’ll have a go at this myself probably early next week (earliest I think I’d be able to do this would be next week).

Just to clarify what you’d end up with. If we made these changes, then this:

  <AuthenticationProvider
    configuration={oidcConfiguration}
    loggerLevel={oidcLog.DEBUG}
  >

Would render no text to the user, but would handle the redirection and callback logic, eventually bouncing a user back into their application on successful login.

Whereas this:

  <AuthenticationProvider
    configuration={oidcConfiguration}
    loggerLevel={oidcLog.DEBUG}
    notAuthenticated={() => <h1>Authenticated!</h1>}
    notAuthorized={() => <h1>Not Authorized!</h1>}
    authenticating={() => <h1>Authenticating</h1>}
    callback={() => <h1>Callback component</h1>}
  >

Would render the respective components.

As to whether the callback is part of this piece of work or not would depend on a discussion between ourselves.

Please let me know what you think!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
youf-oliviercommented, Apr 3, 2019

Hello you both.

I’m working hard on a new version with Hooks. I will introduce the customized component in the version.

The PR will come in few days.

0reactions
citypaulcommented, Jan 2, 2020

Hey @guillaumechervetaxa, sounds cool! Nice work 😃 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

React - How to force a function component to render?
Its setter. Use it to update the value. Updating the value by its setter will force your function component to re-render, just like...
Read more >
How To Customize React Components with Props
In this tutorial, you'll create custom components by passing props to your component. Props are arguments that you provide to a JSX element....
Read more >
React.Component
This page contains a detailed API reference for the React component class ... The render() method is the only required method in a...
Read more >
Custom View Components | Android Developers
If none of the prebuilt widgets or layouts meets your needs, ... will do nothing, and the default onMeasure() will always set a...
Read more >
Create a Custom Renderer | Lightning Aura Components ...
The framework automatically renders your components so you don't have to know anything more about rendering unless you need to customize the default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found