DEV Community

Discussion on: Using the React Context API, the right way (a time saver)

Collapse
 
tommoran profile image
Thomas Moran • Edited

Wouldn't you still need to do a conditional render to show the Auth vs NotAuth components as shown in your third snippet?

Or would you plan on returning both and letting Context worry about which to show

Collapse
 
itays123 profile image
Itay Schechner

My solution is

<Authenticated>You're signed in</Authenticated>
<NotAuthenticated>
Oops, go sign in
</NotAuthenticated>
Enter fullscreen mode Exit fullscreen mode

The reason I like it so much is that you can use one without the other, like the example in the logout button.