
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
react-anchor
Advanced tools
Functional factory to create anchor components that trigger custom actions. Uses
event.preventDefault under the hood.
$ npm i --save react-anchor
var anchorFactory = require('react-anchor');
var open = require('open');
// create factory that generates links
var profileLinkFactory = anchorFactory({
onClick: open,
className: 'profile-link'
});
// create a new `<a>` tag
profileLinkFactory({
href: 'gh/yoshuawuyts',
children: '/yoshuawuyts',
className: 'foo-bar'
});
creates the following component:
var opts = {
className: 'profile-link foo-bar',
href: 'gh/yoshuawuyts',
onClick: handleClick.bind(this)
};
return react.DOM.a(opts, 'gh/yoshuawuyts');
function handleClick(e) {
e.preventDefault();
e.stopPropagation();
open('gh/yoshuawuyts');
}
Create a new anchorFactory, which returns an anchor component.
var AnchorFactory = require('react-anchor');
var router = require('./myRouter');
var anchorFactory = AnchorFactory(router.navigate, 'menu-link');
Call the newly created anchorFactory and create a new anchor tag.
If you're using an object as argument, note that className will extend the class set in the AnchorFactory.
So if the anchorFactory provides .link and you create a tag with class .modal-link you get .link .modal-link.
var anchorTag = anchorFactory({
href: 'gh/yoshuawuyts',
children: '/yoshuawuyts',
className: 'foo-bar'
});
var otherTag = anchorFactory({href: '/hello', className: 'sup'}, 'hello');
FAQs
Functional react anchor factory
We found that react-anchor 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.