Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ToggleDemo() {
const [value1, toggleValue1] = useToggle();
const [value2, toggleValue2] = useToggle(true);
const [value3, toggleValue3] = useToggle("start", customToggleFunction);
return (
<>
<section>
<h3>Base</h3>
<button>{value1.toString()}</button>
<hr>
</section>
<section>
<h3>Initial true</h3>
<button>{value2.toString()}</button>
<hr>
</section>
<section>
<h3>Custom values</h3></section>
function ToggleDemo() {
const [value1, toggleValue1] = useToggle();
const [value2, toggleValue2] = useToggle(true);
const [value3, toggleValue3] = useToggle("start", customToggleFunction);
return (
<>
<section>
<h3>Base</h3>
<button>{value1.toString()}</button>
<hr>
</section>
<section>
<h3>Initial true</h3>
<button>{value2.toString()}</button>
<hr>
</section>
<section>
<h3>Custom values</h3>
<button>{value3}</button></section>
function ToggleDemo() {
const [value1, toggleValue1] = useToggle();
const [value2, toggleValue2] = useToggle(true);
const [value3, toggleValue3] = useToggle("start", customToggleFunction);
return (
<>
<section>
<h3>Base</h3>
<button>{value1.toString()}</button>
<hr>
</section>
<section>
<h3>Initial true</h3>
<button>{value2.toString()}</button>
<hr>
</section>
<section></section>
function UseRafDemo() {
const [shouldRun, toggleShouldRun] = useToggle(true);
const myRef = useRef();
const canvasRef = useRef();
useRaf(() => {
if (canvasRef && canvasRef.current) {
const screenRatio = window.devicePixelRatio || 1;
let angle = updateAngle();
const canvas = canvasRef.current;
var ctx = canvas.getContext("2d");
ctx.save();
ctx.clearRect(0, 0, canvasRef.current.width, canvasRef.current.height);
ctx.scale(screenRatio, screenRatio);
ctx.fillStyle = "midnightblue";
ctx.globalAlpha = 1;
ctx.fillRect(0, 0, canvasRef.current.width, canvasRef.current.height);
ctx.fillStyle = "yellow";
ctx.lineWidth = 2;