# # Dynamically show/hide components

## # How to dynamically show/hide components

From version 8.5.2, three new APIs (keepState, revokeKeepState, isStateKept) are provided to help users show/hide components dynamically. keepState is a function specially provided to the application layer to manage the state of components, and is not be used by Web SDK internally. Currently, it is only valid for show/hide states. Users can first call show/hide function to control the visibility of the component, and then call keepState function to keep the current visibility state. The purpose of using keepState is to prevent SDK from modifying the visibility state at an uncertain time.

Example:

    const redactApplyMenu = await pdfui.getComponentByName('fv--contextmenu-item-apply');

    redactApplyMenu.hide(); // First hide component.
    redactApplyMenu.keepState(); // Keep the current hide state of the component, which prevents the component from being showed inside the SDK.
    // Revoke the keep-state when necessary.
    redactApplyMenu.revokeKeepState();