Last active
November 7, 2017 18:00
-
-
Save trueadm/fe8693eee1758ac9c291b371ae7d0fc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { formatNumber } from "externalLibrary"; | |
import { startAnimate, stopAnimate } from "externalLibrary2"; | |
import { Subscriber } from "externalLibrary3"; | |
import { createRef } from "react-dom"; | |
const someAnimationRef = createRef(); | |
let counter = 0; | |
let name = ""; | |
let subscriber = new Subscriber(); | |
function increment(props, e) { | |
counter++; | |
} | |
export function render(props) { | |
return ( | |
<> | |
{ name && <h2>Hello {name}</h2> } | |
<button onClick={increment}>Counter</button> | |
<span >{ formatNumber(counter) }</div> | |
<div className="someAnimation" ref={someAnimationRef} /> | |
</> | |
); | |
} | |
export async function componentDidMount() { | |
name = await subscriber.subscribe("user.name"); | |
startAnimate(someAnimationRef.contents); | |
} | |
export async function componentWillUnmount() { | |
stopAnimate(someAnimationRef.contents); | |
await subscriber.unsubscribe("user.name"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment