Skip to content

Commit 6ddf14d

Browse files
authored
docs(feedback): Add example for openDialog() (#9481)
1 parent a3ebebc commit 6ddf14d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/feedback/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,29 @@ feedback.attachTo(document.querySelector('#your-button'), {
203203
});
204204
```
205205

206+
Alternatively you can call `feedback.openDialog()`:
207+
208+
```typescript
209+
import {BrowserClient, getCurrentHub} from '@sentry/react';
210+
import {Feedback} from '@sentry-internal/feedback';
211+
212+
function MyFeedbackButton() {
213+
const client = hub && getCurrentHub().getClient<BrowserClient>();
214+
const feedback = client?.getIntegration(Feedback);
215+
216+
// Don't render custom feedback button if Feedback integration not installed
217+
if (!feedback) {
218+
return null;
219+
}
220+
221+
return (
222+
<button type="button" onClick={() => feedback.openDialog()}>
223+
Give me feedback
224+
</button>
225+
)
226+
}
227+
```
228+
206229
### Bring Your Own Widget
207230

208231
You can also bring your own widget and UI and simply pass a feedback object to the `sendFeedback()` function.

0 commit comments

Comments
 (0)