Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { RouteUrls } from '@shared/route-urls';
import type { HasChildren } from '@app/common/has-children';
import { type Nonce, nonceEditorContext as NonceEditorContext } from './nonce-editor.context';
interface NonceEditorProviderProps extends HasChildren {
nonce: Nonce;
onGoBack(): void;
}
export function NonceEditorProvider({
children,
nonce: currentNonce,
onGoBack,
}: NonceEditorProviderProps) {
const [loadedNonce, setLoadedNonce] = useState<Nonce>(currentNonce);
const [nonce, setNonce] = useState<Nonce>(currentNonce);
const navigate = useNavigate();
return (
<NonceEditorContext.Provider
value={{
loadedNonce,
nonce,
onGoBack,
onSetLoadedNonce: (value: Nonce) => setLoadedNonce(value),
onSetNonce: (value: Nonce) => setNonce(value),
onUserActivatesNonceEditor: () => navigate(RouteUrls.NonceEditor),
}}
>
{children}
</NonceEditorContext.Provider>
);
}
|