UNPKG

394 BJavaScriptView Raw
1import * as React from 'react';
2import { generateUID } from './uid';
3export const createSource = (prefix = '') => ({
4 value: 1,
5 prefix: prefix,
6 uid: generateUID(),
7});
8export const counter = createSource();
9export const source = React.createContext(createSource());
10export const getId = (source) => source.value++;
11export const getPrefix = (source) => (source ? source.prefix : '');