Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Im trying to navigate to my shipping page but i keep getting this error

This is the error message

react-dom.development.js:11340 Uncaught TypeError: Cannot read properties of undefined (reading 'search')
at Login (Login.js:21:1)
at renderWithHooks (react-dom.development.js:14985:1)
at mountIndeterminateComponent (react-dom.development.js:17811:1)
at beginWork (react-dom.development.js:19049:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
at invokeGuardedCallback (react-dom.development.js:4056:1)
at beginWork$1 (react-dom.development.js:23964:1)
at performUnitOfWork (react-dom.development.js:22776:1)
at workLoopSync (react-dom.development.js:22707:1)

This is my code

my Login.js

const Login = ({ history, location }) => {

const [email, setEmail] = useState('');
const [password, setPassword] = useState('');

const alert = useAlert();
const dispatch = useDispatch();

const { isAuthenticated, error, loading } = useSelector(state => state.auth);

const redirect = location.search ? location.search.split('=')[1] : '/'

const navigate = useNavigate();
// navigate('/')



useEffect(() => {

    if (isAuthenticated) {
        navigate(redirect)
    }

    if (error) {
        alert.error(error);
        dispatch(clearErrors());
    }

}, [dispatch, alert, isAuthenticated, error, navigate, redirect])


const submitHandler = (e) => {
    e.preventDefault();
    dispatch(login(email, password))
}

return ()} export default Login

the error seems to be coming from my "location.search" because in my vscode that part is line 21. Has there been any recent change in documentation?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Where location & history props come from? If your are using hooks, I assume this should not come from props, but from hooks

import { useHistory, useLocation } from "react-router-dom";

const Login = () => {
  const history = useHistory();
  const location = useLocation();
  ...
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!