diff --git a/blog/2024-11-15-playing-with-fire/1-introduction/Gasket.tsx b/blog/2024-11-15-playing-with-fire/1-introduction/Gasket.tsx index 1b96395..c1d848b 100644 --- a/blog/2024-11-15-playing-with-fire/1-introduction/Gasket.tsx +++ b/blog/2024-11-15-playing-with-fire/1-introduction/Gasket.tsx @@ -1,16 +1,21 @@ -import Canvas, {PainterContext} from "../src/Canvas"; -import {useContext} from "react"; +import {SquareCanvas, PainterContext} from "../src/Canvas"; +import {useContext, useEffect} from "react"; export function Render({f}) { - const {setPainter} = useContext(PainterContext); - setPainter(f); + const {width, height, setPainter} = useContext(PainterContext); + useEffect(() => { + if (width && height) { + const painter = f({width, height}); + setPainter(painter); + } + }, [width, height]); return <>>; } export default function Gasket({f}) { return ( - + ) } \ No newline at end of file diff --git a/blog/2024-11-15-playing-with-fire/1-introduction/GasketWeighted.tsx b/blog/2024-11-15-playing-with-fire/1-introduction/GasketWeighted.tsx index 40d5a3b..326b7f1 100644 --- a/blog/2024-11-15-playing-with-fire/1-introduction/GasketWeighted.tsx +++ b/blog/2024-11-15-playing-with-fire/1-introduction/GasketWeighted.tsx @@ -1,4 +1,4 @@ -import {useEffect, useState, useContext} from "react"; +import {useEffect, useState, useContext, useRef} from "react"; import {PainterContext} from "../src/Canvas"; import {chaosGameWeighted} from "./chaosGameWeighted"; import TeX from '@matejmazur/react-katex'; @@ -30,7 +30,7 @@ export default function GasketWeighted() { const weightInput = (title, weight, setWeight) => ( <>