Unverified Commit 79bef0ff authored by andreswebs's avatar andreswebs
Browse files

add utils/get-key

parent 5007b5f6
/*
Code by Moshe Kolodny
https://github.com/kolodny/weak-key
*/
const map = new WeakMap();
let index = 0;
/**
*
* Generates a simple key for an object, by storing the object in a
* WeakMap. This key can be used in
* React component lists as the property key={}
*
* @param {Object} obj
* @returns {string}
*/
function getKey(obj) {
let key = map.get(obj);
if (!key) {
key = `key-${index++}`;
map.set(obj, key);
}
return key;
}
export { getKey };
......@@ -24,7 +24,7 @@ export function requireAuth(nextState, replace) {
}
}
export const fetchApi = args => {
export function fetchApi(args) {
const { path, body, method } = args;
const url = `${BACKEND_URL}/${path}`;
const newargs = {
......@@ -48,4 +48,6 @@ export const fetchApi = args => {
window.history.go('/login');
}
});
};
}
export * from './get-key';
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment