Apparently a local variable called props will be incorrectly considered to be passed props in a functional component.
function Foo() {
const props = {}
props.bar = 'bar'
return <div {...props} />
}
warning 'bar' is missing in props validation react/prop-types
Following is fine:
class Foo extends Component {
render() {
const props = {}
props.bar = 'bar'
return <div {...props} />
}
}
Worth fixing, but I have no idea why you'd ever want a variable called "props" in a React component :-)
@ljharb FYI
function GenericThankyou({ nextAssignmentId }) {
const cardProps = {}
if (nextAssignmentId == null) {
cardProps.submitText = 'Back to the lobby'
cardProps.onSubmit = navigateTo(RailsRoutes.lobby_path())
} else {
cardProps.submitText = 'Take the next test'
cardProps.onSubmit = navigateTo(RailsRoutes.do_ordered_test_path(nextAssignmentId))
}
return (
<TestStepCard {...cardProps}>
<Title>{translate('test.complete.thank_you_1')}</Title>
<p className='GenericThankyou-text'>
{translate('test.complete.message_1')}
</p>
</TestStepCard>
)
}
(cardProps seems like the better name, since props looks like it's the GenericThankYou props 馃槈)
(agreed, but I decided to report it anyway)
Fixed in #1365
Most helpful comment
(agreed, but I decided to report it anyway)