
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-usa-map
Advanced tools
This is an alternate version for you that just want a simple customizable map on HTML. This maps shows states delimitations including DC, Alaska, and Hawaii. D3 is not needed.
It uses the Albers projection.
Live: http://react-usa-map-demo.herokuapp.com
Code: http://github.com/gabidavila/react-usa-map-demo
It requires react 16.13.1 or higher. Run:
yarn add react-usa-map
or
npm install react-usa-map --save
The below example shows the mandatory onClick event.
import React, { Component } from 'react';
import USAMap from "react-usa-map";
class App extends Component {
/* mandatory */
mapHandler = (event) => {
alert(event.target.dataset.name);
};
render() {
return (
<div className="App">
<USAMap onClick={this.mapHandler} />
</div>
);
}
}
export default App;
Example with optional props, App.js:
import React, { Component } from 'react';
import './App.css'; /* optional for styling like the :hover pseudo-class */
import USAMap from "react-usa-map";
class App extends Component {
/* mandatory */
mapHandler = (event) => {
alert(event.target.dataset.name);
};
/* optional customization of filling per state and calling custom callbacks per state */
statesCustomConfig = () => {
return {
"NJ": {
fill: "navy",
clickHandler: (event) => console.log('Custom handler for NJ', event.target.dataset)
},
"NY": {
fill: "#CC0000"
}
};
};
render() {
return (
<div className="App">
<USAMap customize={this.statesCustomConfig()} onClick={this.mapHandler} />
</div>
);
}
}
export default App;
App.css:
path {
pointer-events: all;
}
path:hover {
opacity: 0.50;
cursor: pointer;
}
| prop | description |
|---|---|
title | Content for the Title attribute on the svg |
width | The width for rendering, numeric, no px suffix |
height | The height for rendering, numeric, no px suffix |
defaultFill | The default color for filling |
customize | Optional customization of filling per state |
Additionally each path tag has an abbreviation of the current state followed by a state class:
<path fill="#{custom color or #D3D3D3}" data-name="CA" class="CA state" d="...{polygon dimensions here}..."></path>
MIT.
The map is sourced from Wikimedia and is under Creative Commons Attribution-Share Alike 3.0 Unported license. This package is inspired on the react-us-state-map package, in fact the initial SVG class system is based on it.
Fork and PR. Not much fuss, I will be try to be as responsive as possible.
Package maintaned by Gabriela D'Ávila Ferrara, website.
FAQs
React component with all USA States with customizable options
The npm package react-usa-map receives a total of 7,488 weekly downloads. As such, react-usa-map popularity was classified as popular.
We found that react-usa-map 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.