SolidJSS
SolidJSโ€ข3y agoโ€ข
14 replies
oneiro

Access native html dialogs show/close methods in clickHandler

Hey folks,

I am currently using native html dialogs inside my app and am accessing their show/close methods by using them from window (e.g. window.myModal.show()). However this is pretty error prone and also doesn't play well with testing.

Is there a recommended way on how to use these without accessing the window? I thought of using refs but apparently these refs are not set, when my handler functions are created, so they stay undefined. ๐Ÿค”

Ideally I would export show/close functions from my component file that could be used everywhere througout the app.

Any idea what would be a good way to solve this?
Was this page helpful?