0.2.0 • Published 2 years ago
@marshallku/react-postscribe v0.2.0
@marshallku/react-postscribe
React component to render HTML with postscribe.
Inspired by react-postscribe.
- Add TypeScript support (both postscribe and react-postscribe)
- Update version of React
- Refactor to function component
- Remove lodash
Made for better albamon mobile MSA
Install
npm install @marshallku/postscribe
# or
yarn add @marshallku/postscribeUsage
import PostScribe from "@marshallku/react-postscribe";
function AdBanner() {
return (
<div className="ad-banner">
<PostScribe html={`<script src="https://example.com/"></script>`} />
</div>
);
}
export default AdBanner;Props
| Property | Type | required | Description |
|---|---|---|---|
| html | string | true | An html string or a function that takes a DOM Document and writes to it. |
| afterAsync | () => void | false | A callback called when an async script has loaded |
| afterDequeue | () => void | false | A callback called immediately before removing from the write queue |
| afterStreamStart | () => void | false | A callback called sync after a stream's first thread release |
| afterWrite | () => void | false | A callback called after writing buffered document.write calls |
| done | () => void | false | A callback that will be called when writing is finished |
| autoFix | boolean | false | A boolean that allows disabling the autoFix feature of prescribe |
| beforeEnqueue | () => void | false | A callback called immediately before adding to the write queue |
| beforeWrite | () => void | false | A callback called before writing buffered document.write calls |
| beforeWriteToken | () => void | false | A callback called before writing a token |
| error | () => void | false | A function that throws the error by default, but could be overwritten |
| releaseAsync | boolean | false | A boolean whether to let scripts w/ async attribute set fall out of the queue |