mirror of
https://github.com/wassname/talk.git
synced 2026-07-24 13:20:47 +08:00
Move uuid generation to TalkContext
This commit is contained in:
@@ -49,6 +49,9 @@ export interface TalkContext {
|
||||
|
||||
/** Browser detection. */
|
||||
browserInfo: BrowserInfo;
|
||||
|
||||
/** Generates uuids. */
|
||||
uuidGenerator: () => string;
|
||||
}
|
||||
|
||||
const { Provider, Consumer } = React.createContext<TalkContext>({} as any);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export default function createUUIDGenerator() {
|
||||
let counter = 0;
|
||||
return () => `uuid-${counter++}`;
|
||||
}
|
||||
@@ -8,3 +8,4 @@ export {
|
||||
default as removeFragmentRefs,
|
||||
NoFragmentRefs,
|
||||
} from "./removeFragmentRefs";
|
||||
export { default as createUUIDGenerator } from "./createUUIDGenerator";
|
||||
|
||||
Reference in New Issue
Block a user