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-aspect-ratio-img
Advanced tools
Render HTML img tag with specific aspect ratio with React. for more information, please see: Document
npm i react-aspect-ratio-img
AspectRatioImg (no IE support
)
Use AspectRatioFence as wrap element to set the aspect ratio and pass <img />
element as children
props into it.
props | type | required | default | description |
---|---|---|---|---|
outerElementType | string | false | div | html tag name of the wrap component |
ratio | number | true | 1 | The aspect ratio of an image describes the proportional relationship between width and height |
className | string | false | - | Custom class name of the wrap component |
src | string | true | - | The URL of an image |
imgAttributes | object | false | - | The attributes of <img /> tag |
children | ReactNode | false | - | Custom children node which as silbing of <img /> tag |
AspectRatioImgLegacy
Use AspectRatioFenceLegacy as wrap element to set the aspect ratio and pass <img />
element as children
props into it.
props | type | required | default | description |
---|---|---|---|---|
outerElementType | string | false | div | html tag name of the outer component |
innerElementType | string | false | div | html tag name of the inner component |
ratio | number | true | 1 | The aspect ratio of an image describes the proportional relationship between width and height |
className | string | false | - | Custom class name of the wrap component |
src | string | true | - | The URL of an image |
imgAttributes | object | false | - | The attributes of <img /> tag |
children | ReactNode | false | - | Custom children node which as silbing of <img /> tag |
SquareImg
Use SquareFence as wrap element and pass <img />
element as children
props into it.
props | type | required | default | description |
---|---|---|---|---|
outerElementType | string | false | div | html tag name of the wrap component |
className | boolean | false | - | Custom class name of the wrap component |
src | string | true | - | The URL of an image |
imgAttributes | object | false | - | The attributes of <img /> tag |
children | ReactNode | false | - | Custom children node which as silbing of <img /> tag |
// import from package entry point
const uc = require('react-aspect-ratio-img')
require('react-aspect-ratio-img/css/style.css')
<uc.AspectRatioImg {...props} />
<uc.SquareImg {...props} />
// only import specific component
const AspectRatioImg = require('react-aspect-ratio-img/lib/components/AspectRatioImg')
require('react-aspect-ratio-img/css/components/AspectRatioImg/style.css')
<AspectRatioImg {...props} />
// import from package entry point
import { AspectRatioImg, SquareImg } from 'react-aspect-ratio-img'
import 'react-aspect-ratio-img/css/style.css'
<AspectRatioImg {...props} />
<SquareImg {...props} />
// only import specific component
import AspectRatioImg from 'react-aspect-ratio-img/es/components/AspectRatioImg'
import 'react-aspect-ratio-img/css/components/AspectRatio/style.css'
<AspectRatioImg {...props} />
npm install
npm start storybook
.storybook
directory.stories
directorynpm run test
__tests__
jest
test:update
to update jest snapshot
<small>2.1.1 (2021-02-21)</small>
FAQs
Set Custom Aspect Ratio Image to the Wrap Element(fence)
We found that react-aspect-ratio-img 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.