Fix useParams null crash on detail pages

useParams() can return null during SSR — destructuring null throws TypeError.
Use optional chaining params?.id to prevent the crash.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-28 17:35:42 -05:00
co-authored by Claude Sonnet 4.6
parent d1f93d6d13
commit 5380a894b1
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -33,7 +33,8 @@ interface ProForm { profession: string; identification: string; address: string;
interface UserForm { name: string; email: string; phone: string; city: string; }
export default function ProfessionalDetailPage() {
const { id } = useParams<{ id: string }>();
const params = useParams<{ id: string }>();
const id = params?.id;
const [professional, setProfessional] = useState<Professional | null>(null);
const [services, setServices] = useState<Service[]>([]);
const [loading, setLoading] = useState(true);
+2 -1
View File
@@ -28,7 +28,8 @@ const PRO_STATE_VARIANTS: Record<number, 'default' | 'secondary' | 'destructive'
interface Form { name: string; city: string; phone: string; gender: string; }
export default function UserDetailPage() {
const { id } = useParams<{ id: string }>();
const params = useParams<{ id: string }>();
const id = params?.id;
const [user, setUser] = useState<UserDetail | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);