Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
react-center-component
Advanced tools
A higher order component decorator to center a component in the window
This is a higher order component decorator. It centers a component with respect to the window.
It listens for when its children are mounted, then it measures the size of these children on the dom. Then it updates the children with appropriate top and left offsets.
Components that are wrapped with this decorator recieve two properties topOffset and leftOffset, they are null before the component has mounted.
When the window is resized, this component will reupdate its children. This process is debounced by 100ms to reduce CPU strain.
// ES7
import React from 'react';
import centerComponent from 'react-center-component';
@centerComponent
export class ModalDialog extends React.Component {
static propTypes = {
topOffset: React.PropTypes.number,
leftOffset: React.PropTypes.number
}
render = () => {
const {topOffset, leftOffset} = this.props;
const dialogStyle = {
position: 'absolute',
width: 100,
height: 100,
top: this.props.topOffset,
left: this.props.leftOffset
}
return (
<div style={dialogStyle}>
Centered
</div>
)
}
}
// ES5
var React = require('react');
var centerComponent = require('react-center-component');
var Component = React.createClass({
...
});
var CenteredComponent = centerComponent(Component);
FAQs
A higher order component decorator to center a component in the window
The npm package react-center-component receives a total of 507 weekly downloads. As such, react-center-component popularity was classified as not popular.
We found that react-center-component 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.