Skip to content

Snapshot delay #384

Answered by d3vl1m3
d3vl1m3 asked this question in Q&A
Apr 22, 2022 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

Okay. Figured it out without using the storiesOf.

You can use this as a custom hook or a component - both seem to work well:

// use-delay-capture.hook.jsx
import {useEffect} from 'react';
import isLokiRunning from '@loki/is-loki-running';
import createAsyncCallback from "@loki/create-async-callback";

const useDelayCapture = (delayInMs = 1000) => {
  useEffect(() => {
    if ( isLokiRunning() ) {
      const onDone = createAsyncCallback();
      const timer = setTimeout(() => onDone(), delayInMs);
      return () => clearTimeout(timer);
    }
  }, [delayInMs]);
}
export default useDelayCapture;

OR

// delay-capture.component.jsx
import React, {useEffect} from 'react';
import isLokiRunning f…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@d3vl1m3
Comment options

@d3vl1m3
Comment options

@d3vl1m3
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by d3vl1m3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants