Client-side collections, but specific to a tracker

So, I’m making a application where I have user validation and I can show in the same page multiple instances of the same component, but they have different IDs that are sent to the subscription that access the same collection but retrieves different data, this data is stored in a collection in the client-side, but its the same collection for both components, is there a way to diferenciate this collection?

Btw, I’m using React as my front-end framework.


I made a hook so I can create collections on the go when they don’t exist, so I can create customizable collections for different sections, changing their names, here how I made their hook:

// meteor
import { Mongo } from 'meteor/mongo';

// npm
import React from 'react';

// collections
const collections: Record<string, Mongo.Collection<any>> = {};

// use collection
export const useCollection = <T = any>(name: string): Mongo.Collection<T> => {
	return React.useMemo(() => {
		if (typeof collections[name] === 'undefined') {
			collections[name] = new Mongo.Collection<T>(name);

		return collections[name];
	}, [name]);

I’m just not sure if thats the best way of doing it, but I hope someone with more experience comes here and corrects me hahaha