Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-outlet
Advanced tools
npm install react-outlet --save
React-Outlet provides two components which aid in cross-component transclusion for React.js, namely an Outlet and Plug component.
Outlets are tied to Plugs via an outletId property. There is a 1-1 relationship between an Outlet and Plug.
An example use-case is a parent page which contains two panels. One panel displays a child component while the other panel contains a couple of other components. Perhaps the parent wants to give the child component the ability to render an additional component in the side panel. Rather than pushing down the entire layout into the child (and potentially duplicating a ton of code between multiple children), with React-Outlet the parent can simply pass an outletId to the child. The child can then render arbitrary content into the parent's panel without loosing control (or causing additional renders).
All of this is done within the React lifecycle and is not async.
This same pattern can be used to build other complex components such as Modals or Tooltips.
var Outlet = require("react-outlet").Outlet;
var Plug = require("react-outlet").Plug;
var Parent = React.createClass({
componentWillMount: function() {
this.setState({
header_outlet: Outlet.new_outlet_id()
});
},
render: function() {
return (
<div>
<Header>
Awesome parent
<Outlet outletId={ this.state.header_outlet } />
</Header>
<Child outlet={ this.state.header_outlet } />
</div>
);
}
});
var Child = React.createClass({
render: function() {
return (
<div>
I am the child
<Plug outletId={ this.props.outlet }>
I will appear in the header.
</Plug>
</div>
);
}
});
Static Methods:
Outlet.new_outlet_id()
Generate and return a new outlet id. Should be passed into Outlet and Plug
components as the outletId prop.
Outlet.reset()
Reset the Outlet's registry. This was added for server-side React usage.
Components:
<Outlet outletId={ outlet_id } />
Render an outlet somewhere in the React component tree. By default this
will render into an empty <div />. Any props other than outletId will be
passed to the underlying <div /> so the outlet is easily classable.
The outletId prop ties this Outlet to a Plug.
<Plug outletId={ outlet_id }>{ ... children go here ... }</Plug>
When a plug has children the children will appear in the associated Outlet
(associated means the outlet has the same outletId as this plug). You can
still use all of the normal React features such as event listeners and so on
on the Plug's children.
I want to give a shout out to Joe Critchley (@joecritchley) who had some great ideas for various outlet/portal implementations. Here are some links to his various implementations:
FAQs
Transclusion helpers for React.js
The npm package react-outlet receives a total of 71 weekly downloads. As such, react-outlet popularity was classified as not popular.
We found that react-outlet 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.