New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-component-click-handler

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-component-click-handler

pass through component for when you need just a click handler to pass back some data

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-component-click-handler

Coverage Status

sometimes all you need when you have a list of data that you're rendering in react is a click handler to forward that data to a method. I ended up not liking creating components that were separate just for this one case. with this you can wrap the jsx in the list rendering to have a click handler, specify the data, and it will give you a click handler that will forward the data for you.

g

Usage

// @flow
import React from 'react'
import ClickHandler from 'react-component-click-handler'

const List = ({ items, onClick }) => (
  <ul>
    {items.map(item => (
      <ClickHandler key={item.id} data={item} onClick={onClick}>
        {(handleClick) => (
          <li onClick={handleClick}>
              {item.text}
          </li>
        )}
      </ClickHandler>
    ))}
  </ul>
)

export default List

check out the tests in the repo for more examples!

ClickHander will not render any DOM elements, it just simply calls children as a function.

FAQs

Package last updated on 13 Sep 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc