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:
co-authored by
Claude Sonnet 4.6
parent
d1f93d6d13
commit
5380a894b1
@@ -33,7 +33,8 @@ interface ProForm { profession: string; identification: string; address: string;
|
|||||||
interface UserForm { name: string; email: string; phone: string; city: string; }
|
interface UserForm { name: string; email: string; phone: string; city: string; }
|
||||||
|
|
||||||
export default function ProfessionalDetailPage() {
|
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 [professional, setProfessional] = useState<Professional | null>(null);
|
||||||
const [services, setServices] = useState<Service[]>([]);
|
const [services, setServices] = useState<Service[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ const PRO_STATE_VARIANTS: Record<number, 'default' | 'secondary' | 'destructive'
|
|||||||
interface Form { name: string; city: string; phone: string; gender: string; }
|
interface Form { name: string; city: string; phone: string; gender: string; }
|
||||||
|
|
||||||
export default function UserDetailPage() {
|
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 [user, setUser] = useState<UserDetail | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user