Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnaya committed Nov 5, 2020
1 parent 88a83a2 commit 0ce1306
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/useObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ function observerComponentNameFor(baseComponentName: string) {
return `observer${baseComponentName}`
}

/**
* We use class to make it easier to detect in heap explorer
*/
class ObjectToBeRetainedByReact {}

export function useObserver<T>(fn: () => T, baseComponentName: string = "observed"): T {
if (isUsingStaticRendering()) {
return fn()
}

const [objectRetainedByReact] = React.useState({})
const [objectRetainedByReact] = React.useState(new ObjectToBeRetainedByReact())

const forceUpdate = useForceUpdate()

Expand Down

0 comments on commit 0ce1306

Please sign in to comment.