Function: useWebshell

â–¸ useWebshell<C, F>(__namedParameters: { features: F ; webViewRef: unknown ; webshellProps: WebshellProps<ComponentProps<C>, F> }): React_2.ComponentProps<C> & { ref: ElementRef<C> }

Inject features into a WebView, enabling capabilities such as:

  • handling messages from the Web environment;
  • sending messages to the Web environment, see WebHandle;
  • running script in the Web environment.

remarks

  • You should always pass all props returned by this hook to the WebView component, and never override any of those props.
  • If you need to pass props to the WebView, use the props parameter field.
  • If you need to pass a reference to the WebView, pass this reference to the webViewRef parameter field.

example

import {
useWebshell,
HandleHashChangeFeature,
HandleVisualViewportFeature
} from '@formidable-webview/webshell';
const features = [
new HandleHashChangeFeature(),
new HandleVisualViewportFeature()
]
const MyCustomWebView = (props) => {
const webViewProps = useWebshell({ features, props });
return <WebView {...webViewProps} />;
}

Type parameters:

NameTypeDescription
CComponentType<any>The type of the WebView component.
FFeature<{}, {}, {}>[]The type for a collection of features to inject.

Parameters:

NameType
__namedParameters{ features: F ; webViewRef: unknown ; webshellProps: WebshellProps<ComponentProps<C>, F> }

Returns: React_2.ComponentProps<C> & { ref: ElementRef<C> }

Props for the WebView component.