DEV Community

Discussion on: 10 Must-Know Patterns for Writing Clean Code with React and TypeScript✨🛀

Collapse
 
glowkeeper profile image
Steve Huckle • Edited

If you want 'private', use closures. Something like:

const friends = () => {
  fetchProfileByID () {} // this probably gets called at initialisation by useEffect

  function render() {
    return // jsx blob
  }

  return { render }
}

const myFriends = friends
myFriends.render()
Enter fullscreen mode Exit fullscreen mode