You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It took me a bit to figure out why I was getting a 'missing in props validation' error in my project. Turns out, returning with a ternary operator was causing the linter to produce this error. Refactoring a bit fixes it. Can anyone else reproduce this?
// @flowimportReactfrom'react'typeProps={x: string}constval=true// ************* The following produces:// 'x' is missing in props validation - eslintreact/prop-typesexportconstproblem=({ x }: Props)=>{returnval ? (<div>{x}</div>) : (<div>Nothing</div>)}// ************ This does not cause an issueexportconstnotProblem=({ x }: Props)=>{constdiv=val ? (<div>{x}</div>) : (<div>Nothing</div>)returndiv}// ************* Nor does thisexportconstalsoNotProblem=({ x }: Props)=>{if(val){return(<div>{x}</div>)}else{return(<div>Nothing</div>)}}
The next version of this package won't recognize functions that start with a lower case as components. Your function problem shouldn't report any errors.
It took me a bit to figure out why I was getting a 'missing in props validation' error in my project. Turns out, returning with a ternary operator was causing the linter to produce this error. Refactoring a bit fixes it. Can anyone else reproduce this?
My eslint config is:
Package versions:
The text was updated successfully, but these errors were encountered: