Question: open new PanelStack after fetching data and pass the returned data to the new panel? #5887
-
QuestionDoes Note: The data I'm fetching is recursive, that's why I'm interested to see if I could use Basically, I want to open a panel after some async action has happened and pass it data return from that action. How many I implement such behavior, if possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The this.props.openPanel({
component: NewPanelComponent
props: {
data: "whatever",
},
title: "cool panel",
}); Do note, however, that props are not changeable after a panel has been opened. The props first used to open the panel will forever be the props of that panel until it is closed. Since you want to load data before opening a panel that shouldn't be an issue, so you could do the following: interface IFolderPanelProps {
contents: IFolder[],
}
class FolderPanel extends React.PureComponent<IFolderPanelProps & IPanelProps> {
public render() {
return <div>{this.props.contents.map(this.renderFolder)}</div>;
}
private renderFolder(folder: IFolder) {
return <div onClick={() => this.openFolder(folder)}>{folder.name}</div>;
}
private openFolder = async (folder: IFolder) => {
const contents = await loadFolderContents(folder.id);
this.props.openPanel({
component: FolderPanel,
props: {
contents,
},
title: folder.name,
});
}
} |
Beta Was this translation helpful? Give feedback.
The
PanelStack
doesn't assume anything, really. You can open new panels from existing panels using theopenPanel
prop:Do note, however, that props are not changeable after a panel has been opened. The props first used to open the panel will forever be the props of that panel until it is closed.
Since you want to load data before opening a panel that shouldn't be an issue, so you could do the following: