I am on the home page (App.js), it displays data, but then I click on one of the data links that redirects to a detailed page with the data (clientdetails.js). On the clientdetails.js page I have a button that can edit the data, when i return to homepage (App.js), I want that data to be re-rendered. How would I do this in react? It currently displays the non-edited data.
App.js code
render(){
const companyInfos = this.state.airlines && this.state.airlines.map((airline, idx) =>
{
if(airline.status == null)
{
airline.status = '';
}
return (
<div className="col-md-2" key={idx} style={{clear: (idx == 0 && idx % 8 == 0) ? 'both' : 'none', 'width': 'auto'}}>
<div className="imgBorder" >
<button type="button" className="close" onClick={() => this.handleClose(airline.airlineName, airline.airlineID)} >
<span >×</span>
</button>
<p key={idx} className="text-center" style={{fontSize:14, color: 'black', backgroundColor: Base64.decode(airline.status) }}> {airline.airlineName + ' ' + airline.product } </p>
<Link to={{
pathname: '/Airlines/airlineName?=' + airline.airlineName +'&product?=' + airline.product + '&monthyear?=' + this.state.Dashboard,
state: {
airlineID: airline.airlineID,
airlineName: airline.airlineName,
airlineProduct: airline.product,
dashboardMonthYear: this.state.Dashboard,
live: this.state.live,
}
}} >
<img className="img-responsive" src={require(`./images/${airline.imageName}`)} />
</Link>
</div>
<br/>
</div>
)
});
}
{companyInfos}
}
Code in the clientdetails.js, save data and the home page function
DelayReturnToHomePage = (e) => {
setTimeout(() => {
this.props.history.push({
pathname: '/'
})
}, 1700)
}
handleSaveData(){
this.setState({
saveDataClicked: 'yes'
})
if(this.state.live == 1)
{
fetch(`http://ca-fpscfb2:4000/SaveDataRedFlags?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&redFlags=${Base64.encode(this.state.redFlagContent)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataMaintenanceReleases?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&maintenanceReleases=${Base64.encode(this.state.maintenanceContent)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataNotes?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}¬es=${Base64.encode(this.state.notesContent)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataStatus?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&status=${Base64.encode(this.state.selectedOption.value)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataSummary?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&summary=${this.state.summaryLiveOn}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataStatusColor?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&statuscolor=${this.state.selectedOption.label}`)
.then(
this.setState({showSaveModal: true}),
setTimeout(() => {
this.handleSaveDataHide();
}, 3000)
)
}
else
{
fetch(`http://ca-fpscfb2:4000/SaveDataRedFlags?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&redFlags=${Base64.encode(this.state.redFlagContent)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataMaintenanceReleases?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&maintenanceReleases=${Base64.encode(this.state.maintenanceContent)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataNotes?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}¬es=${Base64.encode(this.state.notesContent)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataStatus?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&status=${Base64.encode(this.state.selectedOption.value)}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataSummary?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&summary=${this.state.summaryLiveOff}`) &&
fetch(`http://ca-fpscfb2:4000/SaveDataStatusColor?dashboardID=${this.state.dashboardID}&airlineID=${this.state.airlineID}&statuscolor=${this.state.selectedOption.label}`)
.then(
this.setState({showSaveModal: true}),
setTimeout(() => {
this.handleSaveDataHide();
}, 3000)
)
}
}