Fixed the AntD message warning (dynamic theme / context)

This commit is contained in:
2025-12-17 17:18:31 +03:00
parent 9548694f13
commit 8f05d06fb9
2 changed files with 7 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ const PreferencesSelector: React.FC<PreferencesSelectorProps> = ({
onComplete, onComplete,
}) => { }) => {
const [selectedPreferences, setSelectedPreferences] = useState<string[]>([]); const [selectedPreferences, setSelectedPreferences] = useState<string[]>([]);
const [messageApi, contextHolder] = message.useMessage();
const handleTogglePreference = (id: string) => { const handleTogglePreference = (id: string) => {
setSelectedPreferences((prev) => setSelectedPreferences((prev) =>
@@ -59,7 +60,7 @@ const PreferencesSelector: React.FC<PreferencesSelectorProps> = ({
const handleSubmit = () => { const handleSubmit = () => {
if (selectedPreferences.length === 0) { if (selectedPreferences.length === 0) {
message.warning("Please select at least one preference"); messageApi.warning("Please select at least one preference");
return; return;
} }
@@ -68,7 +69,7 @@ const PreferencesSelector: React.FC<PreferencesSelectorProps> = ({
"userPreferences", "userPreferences",
JSON.stringify(selectedPreferences) JSON.stringify(selectedPreferences)
); );
message.success("Preferences saved successfully!"); messageApi.success("Preferences saved successfully!");
onComplete(); onComplete();
}; };
@@ -79,6 +80,7 @@ const PreferencesSelector: React.FC<PreferencesSelectorProps> = ({
animate={{ opacity: 1 }} animate={{ opacity: 1 }}
transition={{ duration: 0.5 }} transition={{ duration: 0.5 }}
> >
{contextHolder}
<Card className={styles.card}> <Card className={styles.card}>
<Title level={2}>Welcome to Tech Master</Title> <Title level={2}>Welcome to Tech Master</Title>
<Text> <Text>

View File

@@ -22,13 +22,14 @@ const { TextArea } = Input;
export default function ContactPage() { export default function ContactPage() {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
const [messageApi, contextHolder] = message.useMessage();
const handleSubmit = async () => { const handleSubmit = async () => {
setSubmitting(true); setSubmitting(true);
// Simulate API call // Simulate API call
setTimeout(() => { setTimeout(() => {
message.success("Your message has been sent successfully!"); messageApi.success("Your message has been sent successfully!");
form.resetFields(); form.resetFields();
setSubmitting(false); setSubmitting(false);
}, 1500); }, 1500);
@@ -55,6 +56,7 @@ export default function ContactPage() {
return ( return (
<main className={styles.main}> <main className={styles.main}>
{contextHolder}
{/* Hero Section */} {/* Hero Section */}
<section className={styles.heroSection}> <section className={styles.heroSection}>
<div className={styles.heroBackground}> <div className={styles.heroBackground}>