summaryrefslogtreecommitdiff
path: root/packages/integrations/react/context.js
blob: 2e3e37fd5dcb75bba3b65499823246f88fc4f7c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const contexts = new WeakMap();

const ID_PREFIX = 'r';

function getContext(rendererContextResult) {
	if (contexts.has(rendererContextResult)) {
		return contexts.get(rendererContextResult);
	}
	const ctx = {
		currentIndex: 0,
		get id() {
			return ID_PREFIX + this.currentIndex.toString();
		},
	};
	contexts.set(rendererContextResult, ctx);
	return ctx;
}

export function incrementId(rendererContextResult) {
	const ctx = getContext(rendererContextResult);
	const id = ctx.id;
	ctx.currentIndex++;
	return id;
}
tr> 2021-10-14Added descriptions to docs pages (#1550)Gravatar AsyncBanana 22-8/+28 2021-10-14Only run `.github/workflows/stats.yml` locally, not on forks (#1549)Gravatar Caleb Jasik 1-0/+1 2021-10-14[ci] collect statsGravatar FredKSchott 1-0/+1 2021-10-13Add Community Themes and separate Featured Theme (#1543)Gravatar Mark Teekman 2-8/+30 * Separate object for featured and community themes I've split up the two so there's the featured one at the top at the page and community ones below the official themes * Add community themes and change featured themes * Add comma after featured object 2021-10-13Change publish date el to be more accessible (#1522)Gravatar AsyncBanana 2-2/+2 2021-10-13[ci] yarn formatGravatar matthewp 1-1/+1 2021-10-13docs: unify concepts in Spanish version (#1545)Gravatar Jorge del Casar 6-11/+11 2021-10-13[ci] yarn formatGravatar matthewp 1-1/+1