Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bberak/react-inline-script

Inject arbitrary javascript and inline <script> tags into your DOM and React app without any hassles.
https://github.com/bberak/react-inline-script

Last synced: 26 days ago
JSON representation

Inject arbitrary javascript and inline <script> tags into your DOM and React app without any hassles.

Awesome Lists containing this project

README

        

# react-inline-script

Inject arbitrary javascript and inline `````` tags into your DOM and React app without any hassles.

## Usage

```javascript
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!")
)
}
}
```

For multiline scripts, just wrap your contents in ```{` /* Your script */ `}```:

```javascript
import React from 'react'
import Script from "react-inline-script"

export default class PageLayout extends React.Component {
constructor(props) {
super(props)
}

render() {
return (



{`
const test = true
if (test)
alert("howdy!")
`}

)
}
}
```