In order to be able to call our bridge injection functions, you need to store the native tag of the WebView component, which acts as an identifier, so you can inject it with Contentsquare bridge later. We do that using the useState hook (1), and setting it to the value of the webview target (2) we get from the onLoadStart callback of the WebView component (3).
2. Call the Contentsquare bridge’s injection/removal functions
In order for the injection and removal to be successful, you should call the bridge when your WebView is fully loaded, and before it is destroyed.
To avoid multiple injections issues, you have to create a new state (1) to set the tag once it is injected (2). You should inject the tag (3) in a function you pass to the onLoadEnd callback of the WebView (4) and remove the injection in the useLayoutEffect (5). Make sure to only inject it once, and pay attention to side effects of useLayoutEffect when states change within your component.