Standardize optional params across repository. #664
-
As it stands, the project is utilizing 2 different ways to create an optional property: interface Props { name: string}
const Test = ({name: ''}: Props) {} interface Props { name?: string}
const Test = ({ name }: Props) {} Subjective opinion aside, one should be swiftly decided on. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
We should weigh in the pros and cons, I cannot comment on the difference as I do not know whats happening here, lets discuss this on Discord |
Beta Was this translation helpful? Give feedback.
-
@decipher-cs your thoughts? |
Beta Was this translation helpful? Give feedback.
-
Explicit over implicit. Let's go with number 2 i.e. |
Beta Was this translation helpful? Give feedback.
-
Alright, we'll just define the type and we'll apply the default values on the prop definition of the component then Something like this, where type ComponentProps {
prop1: 'string'
}
const Comp = ({prop1='hello'}:ComponentProps){
} |
Beta Was this translation helpful? Give feedback.
Alright, we'll just define the type and we'll apply the default values on the prop definition of the component then
Something like this, where
hello
is the default value of prop1 for instance