Add .gitignore to exclude all node packages and lock files
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.useNonce = exports.NonceContext = void 0;
|
||||
const react_1 = require("react");
|
||||
exports.NonceContext = (0, react_1.createContext)({
|
||||
getNonce: () => 0,
|
||||
});
|
||||
const useNonce = () => {
|
||||
const context = (0, react_1.useContext)(exports.NonceContext);
|
||||
const [nonce, setNonce] = (0, react_1.useState)(() => context.getNonce());
|
||||
const lastContext = (0, react_1.useRef)(context);
|
||||
// Only if context changes, but not initially
|
||||
(0, react_1.useEffect)(() => {
|
||||
if (lastContext.current === context) {
|
||||
return;
|
||||
}
|
||||
lastContext.current = context;
|
||||
setNonce(context.getNonce);
|
||||
}, [context]);
|
||||
return nonce;
|
||||
};
|
||||
exports.useNonce = useNonce;
|
||||
Reference in New Issue
Block a user