![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
react-portalize
Advanced tools
Readme
npm i react-portalize
A convenient component for injecting elements into React Portals via DOM selectors. You may optionally choose to render your portals on the server side as well :)
import Portalize from 'react-portalize'
// renders 'Hello' into <div id='portals'/>
<Portalize container='#portals'>
Hello
</Portalize>
// renders 'Hello' into all instances of <div class='portals'/>
<Portalize container='.portals'>
Hello
</Portalize>
// renders 'Hello' into all instances of <section/>
<Portalize container='section'>
Hello
</Portalize>
// renders 'Hello' into all instances of <div data-portalize="why not"/>
<Portalize container='div[data-portalize="why not"]'>
Hello
</Portalize>
<Portalize>
container: string
#portals
children: React.ReactNode
server: boolean
server={false}
flag. You don't need to worry about turning this
off if you aren't rendering on the server with renderPortalsToString
true
providers {provider: React.ReactProvider, value: any}[]
<Provider value={}/>
components wrapped
around them. The providers supplied in the array are reduced from the
right, so [a, b, c]
renders as <a><b><c/></b></a>
.
<Portalize providers={[{provider: YourProvider, value: YourProviderValue}]}>
<YourConsumer>{(value) => JSON.stringify(value)}</YourConsumer>
</Portalize>
renderPortalsToString(html <string>)
<!DOCTYPE html>
string here or
alternatively just the React root generated by
ReactDOMServer.renderToString()
.import {renderPortalsToString} from 'react-portalize/server'
function serverRenderer req, res, next() {
const page = renderPortalsToString(
ReactDOMServer.renderToString(<App/>)
)
res.set('Content-Type', 'text/html').send(`
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello world app</title>
</head>
<body>
<div id="⚛️">${page}</div>
</body>
</html>
`)
}
import {renderPortalsToString} from 'react-portalize/server'
function serverRenderer(req, res, next) {
const page = ReactDOMServer.renderToString(<App />)
res.set('Content-Type', 'text/html').send(
renderPortalsToString(`
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello world app</title>
</head>
<body>
<div id="⚛️">${page}</div>
</body>
</html>
`)
)
}
You will receive a warning message in the console from ReactDOM.hydrate()
in
"development" akin to Did not expect server HTML to contain the text node "Hello" in <div>.
.
This is because ReactDOM.hydrate()
does not expect your portals to be rendered
into the App. You can safely ignore this warning.
MIT
FAQs
```jsx harmony import Portalize from 'react-portalize'
We found that react-portalize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.