Skip to content

Commit ce861a4

Browse files
fix: remove derived state from place bet form
1 parent 9378976 commit ce861a4

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

frontend/src/components/place-bet-form.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { FormEvent, useEffect, useState } from "react";
3+
import { FormEvent, useState } from "react";
44
import clsx from "clsx";
55
import { Market, MarketStatus } from "@/lib/contract/types";
66
import { useWallet } from "@/lib/wallet/use-wallet";
@@ -33,13 +33,11 @@ export function PlaceBetForm({ market, onBetSuccess }: PlaceBetFormProps) {
3333
const [isSubmitting, setIsSubmitting] = useState(false);
3434
const [submitError, setSubmitError] = useState<string | null>(null);
3535
const [successMessage, setSuccessMessage] = useState<string | null>(null);
36-
const [isMarketClosed, setIsMarketClosed] = useState(false);
37-
38-
useEffect(() => {
39-
const now = Math.floor(Date.now() / 1000);
40-
const marketStatus = getMarketStatus(market, now);
41-
setIsMarketClosed(marketStatus !== MarketStatus.Active);
42-
}, [market]);
36+
37+
const now = Math.floor(Date.now() / 1000);
38+
const status = getMarketStatus(market, now);
39+
const isMarketClosed = status !== MarketStatus.Active;
40+
4341

4442
const validateForm = (): boolean => {
4543
const newErrors: FormErrors = {};

0 commit comments

Comments
 (0)