react#HTMLAttributeReferrerPolicy TypeScript Examples

The following examples show how to use react#HTMLAttributeReferrerPolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NodeScript.tsx    From kratos-selfservice-ui-react-nextjs with Apache License 2.0 6 votes vote down vote up
NodeScript = ({ attributes }: Props) => {
  useEffect(() => {
    const script = document.createElement('script')

    script.async = true
    script.setAttribute('data-testid', `node/script/${attributes.id}`)
    script.src = attributes.src
    script.async = attributes.async
    script.crossOrigin = attributes.crossorigin
    script.integrity = attributes.integrity
    script.referrerPolicy =
      attributes.referrerpolicy as HTMLAttributeReferrerPolicy
    script.type = attributes.type

    document.body.appendChild(script)

    return () => {
      document.body.removeChild(script)
    }
  }, [attributes])

  return null
}