Custom Widget Example, Fetches User Id On Every Render

Hi Team,

unfortunately can’t post that as Comment under the Original Post.
But wanted to make you aware that in this post’s example code: https://community.palantir.com/t/how-to-create-a-custom-widget-for-workshop/2182/2

The User Information get’s fetched every render. I think that should be pushed into an useEffect.

Code I reference:

  const [user, setUser] = React.useState<User>();
  const getProfile = React.useCallback(async () => {
    const result = await getCurrent(platformClient);
    setUser(result);
  }, []);
getProfile()

Thanks for pointing this out. You are indeed right !
I’ll correct the original code of the post.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.