मैं हाल ही में प्रतिक्रिया का उपयोग शुरू किया और मैं इस तरह डिफ़ॉल्ट मान परिभाषित करते हैं:defaultProps बनाम तार्किक या
class TextInput extends Component {
render() {
return (
<input
type="text"
name={ this.props.inputName || 'inputName' }
style={ this.props.inputStyle || {} }
className={ this.props.inputClass || '' }
/>
);
}
}
के बजाय:
class TextInput extends Component {
render() {
return (
<input
type="text"
name={ this.props.inputName}
style={ this.props.inputStyle}
className={ this.props.inputClass}
/>
);
}
}
TextInput.defaultProps = {
inputName: 'inputName',
inputStyle: {},
inputClass: ''
}
विपरीत क्या नुकसान इस दृष्टिकोण है defaultProps
उपयोग करने के लिए ?
मुझे लगता है, उत्तर के लिए धन्यवाद – sleepwalker00