The implementation is quite simple: useInstance will create an instance of Instance, and useSynchronizeInstance will simply add methods to it. The instance stays referentially stable throughout its lifetime.
Testing
Added unit test and e2e test, updated stories, updated website examples.
Changes
This adds two new API surfaces to
Dialog
:useInstance
hook containingshow()
/close()
methods for imperative manipulation of dialog.instance
prop which accepts an instance returned from the above hook.Together, this makes it easier to control the dialog without explicitly maintaining its state.
Supersedes #1976
Usage:
The implementation is quite simple:
useInstance
will create an instance ofInstance
, anduseSynchronizeInstance
will simply add methods to it. The instance stays referentially stable throughout its lifetime.Testing
Added unit test and e2e test, updated stories, updated website examples.
Docs
Added docs + jsdocs + changeset.