I came across an issue today, consider following component:
export default class Input extends React.Component {
someFunction() {
console.log(this.props.value)
}
render () {
const { type, value, required } = this.props
return (
<div className={cx('Input')}>
<input type={type} value={value} required={required} />
</div>
)
}
}
I am successfully destrucutring this.props
and can use them within the render, however what if I need to use prop values outside of it i.e. inside someFunction()
I am not sure to what would the consequences be if I move out constant { ... }
and include right after export default class Input extends React.Component {
line. Will this still be valid?