{"size": 272, "ext": "js", "max_stars_repo_path": "packages/codistica-react/src/hooks/use-singleton.js", "max_stars_repo_name": "codistica/codistica-js", "max_stars_repo_stars_event_min_datetime": "2020-04-05T23:30:14.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-11T19:42:26.000Z", "max_issues_repo_path": "packages/codistica-react/src/hooks/use-singleton.js", "max_issues_repo_name": "codistica/codistica-js", "max_issues_repo_issues_event_min_datetime": "2020-04-20T17:58:41.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-26T15:49:02.000Z", "max_forks_repo_path": "packages/codistica-react/src/hooks/use-singleton.js", "max_forks_repo_name": "codistica/codistica-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 10, "max_issues_count": 9, "max_forks_count": null, "avg_line_length": 16.0, "max_line_length": 57, "alphanum_fraction": 0.5367647059}
/** @flow */

import {useRef} from 'react';

function useSingleton(cb: (...args: Array<any>) => any) {
    const called = useRef(false);
    if (called.current) {
        return;
    }
    if (cb) {
        cb();
    }
    called.current = true;
}

export {useSingleton};
