I am trying to create unique ids for my React components. I have created this modules:
var _uid: number = 0;
function getUid(): string {
++_uid;
return `_uid_${_uid}`;
}
export default getUid;
Hoping that the _uid would be increased every time the module function is called, but it is always 1. How can I achieve increase it every time the module is required?
via Victor
No comments:
Post a Comment