in Education by
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)

1 Answer

0 votes
by
The real answer is that by convention you don't really want to extend components other than React.Component as functional composition is the primary way of abstraction in React. In other words: You should nest components, rather than extending classes in React.

Related questions

0 votes
    I'm using an abstract superclass for some React components that share methods and some (but not all) props ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    This is the example table that I want to do From the 'Yellow' highlight (row & column) color. I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
0 votes
    Check out this example code I saw: import * as React from 'react'; const Count: React.FunctionComponent ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    i'm messing with React and i was trying to make some transition between the router pages. Before using ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I have a React User Profile page that retrieves User object from back-end. User profile object contains a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I have been having some issues with LINQ-To-SQL around memory usage. I'm using it in a Windows ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I have been having some issues with LINQ-To-SQL around memory usage. I'm using it in a Windows ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I have been having some issues with LINQ-To-SQL around memory usage. I'm using it in a Windows ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    When do you have to avoid using secondary indexes (1)On columns containing high count of unique values (2)Use ... (4)can use it on any columns without effecting performance...
asked May 6, 2021 in Technology by JackTerrance
...