-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Feature/14 add custom params for topics creation #20
Feature/14 add custom params for topics creation #20
Conversation
|
||
interface Props { | ||
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void, | ||
btnColor: string; |
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.
let's use className
instead.
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.
- <CustomParamButton btnColor="is-danger" btnIcon='fa-minus' onClick={() => onRemove(index)} />
+ <CustomParamButton
+ className="is-danger"
+ type='minus'
+ onClick={() => onRemove(index)}
+/>
enum CustomParamButtonType {
plus=
minus=
}
interface Props {
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void,
className: string;
type: CustomParamButtonType;
}
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.
good suggestion! thanks!
</> | ||
); | ||
|
||
export default React.memo(CustomParamOptions); |
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.
🥇
const optInputName = `${index}[name]`; | ||
|
||
React.useEffect( | ||
() => { if (isFirstParam(index)) { unregister(optInputName) } }, |
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.
we need to add eslint ASAP
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.
let me add it in a separate task =)
); | ||
|
||
const selectedMustBeUniq = (selected: string) => { | ||
const values: any = getValues({ nest: true }); |
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.
any?
const { register, unregister, errors, watch, setValue } = useFormContext(); | ||
const selectInputName: string = `${index}[name]`; | ||
const valInputName: string = `${index}[value]`; | ||
const selectedParamName: any = watch(selectInputName, name); |
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.
any?
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.
I'm a typescript newbie =) Not sure how to handle this if things like watch()
, getValues()
return undefined
which is ok?
const selectedParamName = watch(selectInputName, name);
const selectedParamName: string = watch(selectInputName, name);
but if I do this way, I start getting typescript warnings like: Type 'uknown' is not assignable to type 'string' or Type 'unknown' cannot be used as an index type.
Please do suggest a correct option
import CustomParamValue from './CustomParamValue'; | ||
import CustomParamAction from './CustomParamAction'; | ||
|
||
const DEF_INDEX = 'default'; |
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.
DEFAULT_INDEX
…params-for-topics-creation Feature/14 add custom params for topics creation
#14