feat(ContextMenu): Introduce new API for imperative rendering #7391
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request:
This PR introduces a new rendering API for the
showContextMenu
andhideContextMenu
options and deprecates the old API. The old API will be dropped in Blueprint 6.Previously these functions would allow users to pass in an object with
domRenderer
anddomUnmounter
options which were implemented viaReactDOM.render
andReactDOM.unmountComponentAtNode
respectively. This API does not work for React 18 which requires tracking a root node between the render and unmount stages. To allow for this, the new API instead allows passing a singlerender
function which should return a function that unmounts the rendered node.The default implementation still uses React 16 compatible defaults as before. In Blueprint 6 we will be making a few breaks here:
DOMMountOptions<T>
type from theoptions
prop ofshowContextMenu
hideContextMenu
render
method to use React 18 compatible methods. It will look something like: