react-inline-script
v1.2.0
Published
Inject arbitrary javascript and inline <script> tags into your DOM without any headaches
Downloads
7,529
Readme
react-inline-script
Inject arbitrary javascript and inline <script>
tags into your DOM and React app without any hassles.
Usage
import React from 'react'
import Script from "react-inline-script"
export default class PageLayout extends React.Component {
constructor(props) {
super(props)
}
render() {
return (
<div id="some-content">
<Script>alert("hi there!")</Script>
</div>)
}
}
For multiline scripts, just wrap your contents in {` /* Your script */ `}
:
import React from 'react'
import Script from "react-inline-script"
export default class PageLayout extends React.Component {
constructor(props) {
super(props)
}
render() {
return (
<div id="some-content">
<Script>
{`
const test = true
if (test)
alert("howdy!")
`}
</Script>
</div>)
}
}