mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-27 01:03:08 +03:00
will no longer be blank profile after fast refresh
This commit is contained in:
parent
5ab8f18870
commit
e037edcc9a
@ -189,6 +189,7 @@ export default class ApplicationPage extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_handleUpdateData = ({ data }) => {
|
_handleUpdateData = ({ data }) => {
|
||||||
|
//TODO(martina): maybe add a default window.history.replacestate where it pushes the new data to browser?
|
||||||
this.setState({ data });
|
this.setState({ data });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ export default class SceneProfile extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount = async () => {
|
componentDidMount = async () => {
|
||||||
|
console.log("component did mount called");
|
||||||
await this.fetchProfile();
|
await this.fetchProfile();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ export default class SceneProfile extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchProfile = async () => {
|
fetchProfile = async () => {
|
||||||
const username = this.props.page.user;
|
const username = this.props.page.user || this.props.page.data?.username;
|
||||||
let query;
|
let query;
|
||||||
let targetUser;
|
let targetUser;
|
||||||
if (username) {
|
if (username) {
|
||||||
@ -65,7 +66,11 @@ export default class SceneProfile extends React.Component {
|
|||||||
targetUser = response.data;
|
targetUser = response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.history.replaceState(window.history.state, "A slate user", `/${targetUser.username}`);
|
window.history.replaceState(
|
||||||
|
{ ...window.history.state, data: targetUser },
|
||||||
|
"A slate user",
|
||||||
|
`/${targetUser.username}`
|
||||||
|
);
|
||||||
|
|
||||||
this.props.onUpdateData({ data: targetUser });
|
this.props.onUpdateData({ data: targetUser });
|
||||||
this.setState({ profile: targetUser });
|
this.setState({ profile: targetUser });
|
||||||
|
Loading…
Reference in New Issue
Block a user