-
-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metadata to dialogs.open() #4377
Comments
What do you mean by metadata? The payload can already take any arbitrary object - we're working on an example to make that clearer in the docs here #4375 |
Semantically, a payload and metadata are distinct. While the payload can be used to pass an object, metadata refers to the data required by the payload. |
We don't assign any semantic meaning to naming of the "payload" parameter. All it does is pass some data into the dialog. You are completely free to lay out an object with the exact semantics that make sense for your use-case. You can encode this layout in an interface and use the generic parameter on interface MyPayload {
data: {/* ... */};
metadata: {/* ... */};
}
function MyDialog({ payload, open, onClose }: DialogProps<MyPayload>) {
const { data, metadata } = payload
// ...
}
// ...
await dialogs.open<MyPayload>(MyDialog, {
data: {/* ... */},
metadata: {/* ... */}
}) Can you elaborate more on the specific use-case that this feature would unlock, and a concrete proposal for an API? |
I agree with you that payload is a catch-all prop, however, in my mind, payload is more relevant to the rendered component inside the dialog and meta would be relevant to any parameter consumed by said component. However, that is just a suggestion, feel free to ignore. |
Summary
It would be helpful to add a metadata prop to dialogs.open() so that the metadata can be accessed in the associated component—enabling a wide range of use cases.
Examples
No response
Motivation
No response
Search keywords: usedialogs metadata
The text was updated successfully, but these errors were encountered: