I'm using an abstract superclass for some React components that share methods and some (but not all) props.
class AbstractStory extends Component { ... }
AbstractStory.propTypes = {
storyForm: PropTypes.string,
timestamp: PropTypes.number
}
class NewContentStory extends AbstractStory { ... }
I'm assuming that if the propTypes of the subclass don't differ from the superclass, I can leave them undeclared on the subclass, and they will be inherited from the superclass.
But, if there are additional properties of the subclass, is there a good way to declare them without restating what is declared on the superclass? Is there any issues doing it like this?
NewContentStory.propType = {... AbstractStory, newProp: PropTypes.string}
What about if the subclass modifies a property declared on the superclass (making it required, adding shape to an object, etc.)?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)