Si estas usando React-Router-Dom v6 una solucion es usar el hook useNavigate
import React, { useContext, useRef } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { AppContext } from '../context/AppContext.js'
import '../styles/components/Information.css';
const Information = () => {
const { state , addToBuyer } = useContext(AppContext);
const form = useRef(null);
const navigate = useNavigate()
const handleSubmit = () => {
const formData = new FormData(form.current);
const buyer = {
name: formData.get('name') ,
email: formData.get('email'),
address: formData.get('address') ,
apto: formData.get('apto'),
city: formData.get('city'),
country: formData.get('country'),
state: formData.get('state'),
cp: formData.get('cp'),
phone: formData.get('phone'),
}
addToBuyer(buyer);
navigate('/checkout/payment')
}
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?