Sadece neler olup bittiğinden emin değilim, bu beklenen davranış ya da değil. arasındaPOP geçmişi, location.state işlevini temizler mi?
Birincisi,
/path1
const state = {
action:() => {},
other: 'other'
}
this.props.history.replaceState(state, '/path2')
sonra ben bu bazı rota /path2
this.props.history.replaceState(this.props.location.state, '/path3')
etrafında devlet gönderecek yerin devlet etrafında işlevi ne göndermek için konumun durumunu kaydedersem, action
hala orada
go back
gerçekleştirdiğinizde
console.log(this.props.location.state) // print { action: fn(), other: 'other' }
Ama şu anda ben /path1
console.log(this.props.location.state) // print { other: 'other' }
Sizler function
yerin durumuna kaldırılır görebilirsiniz rota am. Sorum şu: Bu neden oluyor? Bunun arkasında bir sebep var mı?
console.log(this.props.location.state) // print { action: {}, other: 'other' }
şimdiden teşekkürler gibi
Ben
const state = {
action: { moreAction:() => {} },
other: 'other'
}
this.props.history.replaceState(state, '/path2')
tarayıcıya geri gitmek gerçekleştirmek Örneğin Nesne içine
function
koymak bile, yerin devlet yine de
Evet, benim yaptığımın konum durumunun amacı olmadığını biliyorum, ama bir sebepten dolayı, bunu belirli bir durum için yapmam gerekiyor. Aslında etrafta işlev geçebiliyorum, ama ne yazık ki geri döndüğümde, temizlendi. – Krit