0

I am passing Data Through route State to open Contact Detail Page

Here is my Website You can Check The error When Click on Name Click Here

Here is How I am passing data

<Link to={`/contactdetail/${curlElem.name}`} state={{name: curlElem.name, email: curlElem.email}}>
<h4 className='header'>{curlElem.name}</h4>
<p>Email:{curlElem.email}</p>
</Link>

And Here You can See How i am receiving on Contact Detail Page to get COntact Details

import React from 'react'
import me from "../images/me3.jpg"
import {Link} from "react-router-dom"
import {useLocation} from "react-router-dom"
const ContactDetail = () => {
  const location=useLocation();
  const {name,email}=location.state;
  // console.log(props.detailcontact);
  // const{id,name,email}=props.detailcontact;
  return (
   <div className='main'>
    <div className='ui card centered'>
      <div className='image'>
<img src={me} alt="me"/>
      </div>
<div className='content'>
<div className='header'>Name:{name}</div>
<div className='discription'>Email:{email}</div>
</div>
<div className="center-div">
<Link to="/">
<div><button className='ui button blue centered'>Back to Contact</button></div>
</Link>
</div>
    </div>
   
   </div>
  )
}

the issue is when i go to contact Detail Page and refresh it i got an error

Kamran Ali
  • 59
  • 7
  • This appears to be a Netlify server deployment issue and not any React state/route state issue. The error is saying it can't find the page, i.e. it returns a 404. Check the CRA [deployment](https://create-react-app.dev/docs/deployment/#netlify) docs for Netlify to see how you can configure your app/server to handle nested page requests. – Drew Reese Jul 21 '22 at 16:29
  • Got it There is no error on Local host But I didn't Find any soluton How to tackle it on Netlify – Kamran Ali Jul 21 '22 at 16:36

1 Answers1

0

Update!.................... It was Not an Error of Route/state It was an error of Netlify

I solved it by Doing Adding netlify.toml file in Route Directory

[build]
command="npm run build"
publish="/build"
base="/"

[[redirects]]
from="/*"
to="/index.html"
status=200
Kamran Ali
  • 59
  • 7