Back to Clerk

`withClerk` function removed

packages/upgrade/src/versions/core-2/common/withclerk-hof-removed.md

latest721 B
Original Source

The withClerk higher order function has been removed. If you would still like to use this function in the way its implemented, it can be created quickly using Clerk's custom hooks. An example of how to do so is below:

js
function withClerk(Component, displayName) {
  displayName = displayName || Component.displayName || Component.name || 'Component';
  Component.displayName = displayName;
  const HOC = props => {
    const clerk = useIsomorphicClerkContext();

    if (!clerk.loaded) return null;

    return (
      <Component
        {...props}
        clerk={clerk}
      />
    );
  };

  HOC.displayName = `withClerk(${displayName})`;
  return HOC;
}