1.1.1 • Published 6 years ago
react-clickable-hoc v1.1.1
react-clickable-hoc
Executes onClick to keyboard actions for improved accessibility of your React components.
Pressing Enter or the space bar (onKeyDown) on the wrapped component will trigger onClick, if it exists.
Installation
Requires React v16.
npm install --save react-clickable-hocUsage
Simply import the module and wrap a component with it !
import clickable from 'react-clickable-hoc';
import Component from './path/to/Component';
// Wrap the component using react-clickable-hoc.
const WrappedComponent = clickable(Component);
render() {
const onClick = () => { console.log('clicked !') };
// Use it like a normal component.
return <WrappedComponent onClick={onClick} />
}