Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
react-usa-svg
Advanced tools
npm i --save react-usa-svg
yarn add react-usa-svg
// TypeScript
import { USA, USAProps } from "react-usa-svg";
function MyConponent(props: USAProps) {
return <USA {...props} />;
}
// JavaScript
import { USA } from "react-usa-svg";
function MyComponent(props) {
return <USA {...props} />;
}
// Any US state abbreviature
type StatesAbbr = 'AL' | 'AK' | ... | "WY";
// Props passed directly to <USA /> component
type USAProps = {
// Extra control on every US state SVG renderer
HOC?: (props: {
renderer: React.FC<{
svg_props: React.SVGProps<SVGPathElement>;
}>;
svg_props?: SVGProps<SVGPathElement>;
abbr: StatesAbbr;
}) => JSX.Element;
// Want to get <path /> element props based on specific state?
getSVGProps?: (abbr: StatesAbbr) => SVGProps<SVGPathElement>;
// SVG filter elements will be rendered inside main <svg> component
SVGFilters?: Array<React.FC<React.SVGProps<SVGFilterElement>>>;
// Props for additional frames
framesStroke?: string;
framesStrokeWidth?: string | number;
};
Or take a look at similar simplified example below:
import { USA, USAProps } from "react-usa-svg";
function SVGMapComponent() {
let [activeState, setActiveState] = React.useState(null);
let props: USAProps = {
SVGFilters: [
() => (
<filter id="filterDropShadow">
<feDropShadow dx="0.2" dy="0.4" stdDeviation="1" />
</filter>
),
],
HOC: ({ renderer: Renderer, svg_props, abbr }) => {
let svg_props_override = {
onMouseEnter: () => {
setActiveState(abbr);
},
onMouseLeave: () => {
setActiveState(null);
},
fill: activeState === abbr ? `purple` : "green",
stroke: activeState === abbr ? `white` : undefined,
strokeWidth: activeState === abbr ? `2px` : undefined,
filter: activeState === abbr ? "url(#filterDropShadow)" : undefined,
};
return (
<Renderer
svg_props={{
...svg_props,
...svg_props_override,
}}
/>
);
},
};
return <USA {...props} />;
}
FAQs
React.js SVG-components for USA map
The npm package react-usa-svg receives a total of 1 weekly downloads. As such, react-usa-svg popularity was classified as not popular.
We found that react-usa-svg 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.