-
Notifications
You must be signed in to change notification settings - Fork 75
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
Added ability to customize html-static-task-example
submit button
#879
Changes from 6 commits
af07a50
feec532
5938013
4eabea1
5fc4412
40a09f9
d65b46c
0d5086c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.md | ||
**/build/* | ||
docs/web/static/python_api/* | ||
wrap_crowd_source.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useState, useCallback, useEffect } from "react"; | ||
|
||
/** | ||
* This hook is to be used with events that are supposed to update state when they are consumed. | ||
* @param {string} eventName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small nit: I would rename I consider |
||
* @param {any} defaultValue | ||
* @param {function} validatorFunction | ||
* @returns [any any] | ||
*/ | ||
export function useMephistoGlobalConfig( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this method looks great implementation-wise! Thanks for the jsdocs as well :) |
||
eventName, | ||
defaultValue, | ||
validatorFunction | ||
) { | ||
const [configState, setConfigState] = useState(defaultValue ?? false); | ||
|
||
const handleEvent = useCallback( | ||
(eventValue) => { | ||
if (validatorFunction) { | ||
if (validatorFunction(eventValue)) { | ||
setConfigState(eventValue); | ||
} | ||
} else setConfigState(eventValue); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. both conditional paths are calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nvm, i see one is for the outer branch |
||
}, | ||
[setConfigState] | ||
); | ||
|
||
useEffect(() => { | ||
window._MEPHISTO_CONFIG_.EVENT_EMITTER.on(eventName, handleEvent); | ||
}, [setConfigState]); | ||
|
||
return [configState, setConfigState]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was the rationale behind removing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a mistake, I don't even know how that got updated.