@shopify/react-html
Version:
A component to render your react app with no static HTML.
24 lines (19 loc) • 538 B
text/typescript
import {getSerializationsFromDocument} from './utilities';
export default class Manager {
private isServer = typeof document === 'undefined';
private serializations = getSerializationsFromDocument();
set(id: string, data: unknown) {
if (this.isServer) {
this.serializations.set(id, data);
}
}
get<T>(id: string): T | undefined {
return this.serializations.get(id) as T | undefined;
}
extract() {
return [...this.serializations.entries()].map(([id, data]) => ({
id,
data,
}));
}
}