react-component / react-component/picker
crash on disabledSeconds is not a function
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 304
- Forks
- 345
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 7
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch rc-picker@3.14.6 for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/rc-picker/es/hooks/useTimeSelection.js b/node_modules/rc-picker/es/hooks/useTimeSelection.js
index 9c4d47c..8f272be 100644
@@ -14,7 +14,7 @@ export default function useTimeSelection(_ref) {
var mergedHour = newHour < 0 ? generateConfig.getHour(now) : newFormattedHour;
var mergedMinute = newMinute < 0 ? generateConfig.getMinute(now) : newMinute;
var mergedSecond = newSecond < 0 ? generateConfig.getSecond(now) : newSecond;
- var newDisabledMinutes = disabledMinutes && disabledMinutes(mergedHour);
+ var newDisabledMinutes = disabledMinutes && typeof disabledMinutes=== "function" && disabledMinutes(mergedHour);
if (newDisabledMinutes !== null && newDisabledMinutes !== void 0 && newDisabledMinutes.includes(mergedMinute)) {
// find the first available minute in minutes
var availableMinute = minutes.find(function (i) {
@@ -26,7 +26,7 @@ export default function useTimeSelection(_ref) {
return null;
}
}
- var newDisabledSeconds = disabledSeconds && disabledSeconds(mergedHour, mergedMinute);
+ var newDisabledSeconds = disabledSeconds && typeof disabledSeconds === "function" && disabledSeconds(mergedHour, mergedMinute);
if (newDisabledSeconds !== null && newDisabledSeconds !== void 0 && newDisabledSeconds.includes(mergedSecond)) {
// find the first available second in seconds
var availableSecond = seconds.find(function (i) {
This issue body was partially generated by patch-package.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in node_modules/rc-picker/es/hooks/useTimeSelection.js and inspect how disabledMinutes and disabledSeconds are invoked during time selection. Reproduce the reported crash with a non-function disabledSeconds value, then verify that valid disabled callbacks still work and the non-function case no longer crashes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100