Skip to content

Visualize Your Ideas With Code

docs: fix bugs in example Switch component (#500)

Teguh Hofsteea64ad47be483
diff --git a/packages/examples/src/components/Switch.tsx b/packages/examples/src/components/Switch.tsx
index c95fd7c3..2bbd1eb9 100644
--- a/packages/examples/src/components/Switch.tsx
+++ b/packages/examples/src/components/Switch.tsx
@@ -39,13 +39,13 @@ export class Switch extends Node {
...props,
});
- this.indicatorPosition(this.initialState ? 50 : -50);
this.isOn = this.initialState();
+ this.indicatorPosition(this.isOn ? 50 : -50);
this.add(
<Rect
ref={this.container}
- fill={this.offColor}
+ fill={this.isOn ? this.accent() : this.offColor}
size={[200, 100]}
radius={100}
>