Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid cloning elements in Authenticated #7203

Merged
merged 3 commits into from
Feb 8, 2022

Conversation

djhi
Copy link
Collaborator

@djhi djhi commented Feb 8, 2022

No description provided.

@djhi djhi added the RFR Ready For Review label Feb 8, 2022
@djhi djhi added this to the 4.0.0-alpha.3 milestone Feb 8, 2022
useAuthenticated({ params: authParams });
// render the child even though the useAuthenticated() call isn't finished (optimistic rendering)
// the above hook will log out if the authProvider doesn't validate that the user is authenticated
return cloneElement(children, rest);
return children;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd prefer that you return <>{children}</>, this makes TypeScript happier.

also, please type children as ReactNode instead of ReactElement to allow multiple children, e.g.

const Foo = () => (
  <Authenticated>
    <Bar />
    <Baz />
  </Authenticated>
);

@fzaninotto fzaninotto merged commit 19c66a6 into next Feb 8, 2022
@fzaninotto fzaninotto deleted the avoid-clone-element-authenticated branch February 8, 2022 15:23
@fzaninotto fzaninotto mentioned this pull request Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants