Skip to content

Commit

Permalink
feat: add live example for useCircuitBreaker hook
Browse files Browse the repository at this point in the history
  • Loading branch information
tachikawa committed Jul 7, 2021
1 parent f11d7ba commit 5b2b03b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions example/src/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import React from 'react'

import { useMyHook } from 'react-use-circuit-breaker'
import { useCircuitBreaker } from 'react-use-circuit-breaker'

const App = () => {
const example = useMyHook()
const [send] = useCircuitBreaker(3, 2000, () => {
throw new Error("The breaker trips!");
});

return (
<div>
{example}
If you push below button 3 times in 2 seconds, then an error will occur(please check devtools for browser)
<div>
<button onClick={() => send().then(() => {})}>PUSH</button>
</div>
</div>
)
}
Expand Down

0 comments on commit 5b2b03b

Please sign in to comment.