Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add useBarcodeScanner hook #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kaisheng1
Copy link

Keep the original BarcodeScanner component and introduce new React hook useBarcodeScanner.

@kybarg kybarg changed the title Add useBarcodeScanner (React hook) as an option feat: add useBarcodeScanner hook Apr 4, 2020
Copy link
Owner

@kybarg kybarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if we refactor component as well to use hook api? Cause now I see we have same code copied, at least we can make Component and Hook to share same code base

export { default as BarcodeScanner } from './BarcodeScanner';
export { default as useBarcodeScanner } from './useBarcodeScanner';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add export default BarcodeScanner not to break previous api

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fine as well, I was just giving an option so people can import like this
import {BarcodeScanner, useBarcodeScanner} from 'react-barcode-scanner'

But yeah, I didn't think about it when I made this change. I'll fix it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring the component or the hook is totally up to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants