react-shortcuts icon indicating copy to clipboard operation
react-shortcuts copied to clipboard

Add a ShortcutsProvider

Open greena13 opened this issue 6 years ago • 4 comments

The current installation instructions require the user to manually add a shortcut manager instance to the shortcuts attribute of their react application's context.

This is extra work for users of the library that React Shortcuts can do automatically (as is done in popular libraries like react-router and react-redux).

This pull request adds a ShortcutsProvider component that can be used to wrap a React application and provides a cleaner, easier-to-use API for users of React Shortcuts. It removes an installation step and reduces the chance the library will be set up incorrectly.

It can be used like so:

import keymap from './keymap'
import { ShortcutsProvider } from 'react-shortcuts'

// ...

<ShortcutsProvider keymap={ keymap } >
   <MyApplication >

   </MyApplication>
</ShortcutsProvider>

greena13 avatar Oct 15 '17 18:10 greena13

@greena13 Thank you for your amazing work. I'll get to those PRs in a few days (I'm just traveling).

petrbrzek avatar Oct 15 '17 21:10 petrbrzek

No problem, @petrbrzek. Thanks for letting me know to expect a delay.

I have a few more suggestions that I will draft up as pull requests, that you can look over when it is next convenient for you to do so. Safe travels.

greena13 avatar Oct 15 '17 22:10 greena13

+1 would love to see these changes merged into a release.

Talking about release - the latest release was 1.6.2, but the package.json in master has a v2.0.0 version which was never published to npm. I also see that the current build is failing in Travis with yarn related warnings.

This library is the closest to what I was imagining a good react keybinding lib should be. I was going to write a new one using mousetrap, and found this library by following a bunch of issues from mousetrap. I see that development has apparently stalled since mid-October. @petrbrzek is there a plan to maintain this library? I have some time on my hands currently and would like to contribute here if possible.

kumarharsh avatar May 08 '18 08:05 kumarharsh

As the legacy context API is being removed from React this PR is gaining traction.

@petrbrzek is there any plan on your side on moving forward with project ?

qpre avatar Jul 30 '18 10:07 qpre