Skip to content

Instantly share code, notes, and snippets.

@trueadm
Last active November 7, 2017 18:00
Show Gist options
  • Save trueadm/fe8693eee1758ac9c291b371ae7d0fc5 to your computer and use it in GitHub Desktop.
Save trueadm/fe8693eee1758ac9c291b371ae7d0fc5 to your computer and use it in GitHub Desktop.
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