<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>why we use constructor and super in react js - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/why-we-use-constructor-and-super-in-react-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/why-we-use-constructor-and-super-in-react-js/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 21 Mar 2022 09:29:59 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>why we use constructor and super in react js - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/why-we-use-constructor-and-super-in-react-js/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What is the purpose of using super constructor with props argument ?</title>
		<link>https://www.wikitechy.com/interview-questions/reactjs/what-is-the-purpose-of-using-super-constructor-with-props-argument/</link>
					<comments>https://www.wikitechy.com/interview-questions/reactjs/what-is-the-purpose-of-using-super-constructor-with-props-argument/#respond</comments>
		
		<dc:creator><![CDATA[webmaster]]></dc:creator>
		<pubDate>Mon, 21 Mar 2022 09:29:59 +0000</pubDate>
				<category><![CDATA[ReactJS]]></category>
		<category><![CDATA[super(props) in React]]></category>
		<category><![CDATA[superprops in functional component]]></category>
		<category><![CDATA[superprops react]]></category>
		<category><![CDATA[what is constructor in react]]></category>
		<category><![CDATA[what is constructorprops in react]]></category>
		<category><![CDATA[what is super in react constructor]]></category>
		<category><![CDATA[what is superprops]]></category>
		<category><![CDATA[what is the purpose of using super constructor with props argument]]></category>
		<category><![CDATA[What's the difference between super() and super(props) in React]]></category>
		<category><![CDATA[Why Do We Write super(props)?]]></category>
		<category><![CDATA[why use super in constructor javascript]]></category>
		<category><![CDATA[why use super in constructor react]]></category>
		<category><![CDATA[why we pass props in constructor]]></category>
		<category><![CDATA[why we use constructor and super in react js]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=3948</guid>

					<description><![CDATA[This method has been known as, a child class constructor cannot create use of this reference until super() . The same applies for ES6 sub-classes as well. The main reason of passing props parameter to super() call is to access this.props in your child constructors. The super() is a requirement, while implementing the constructor() function inside a React component. [&#8230;]]]></description>
										<content:encoded><![CDATA[<ul>
<li style="text-align: justify;">This method has been known as, a child class constructor cannot create use of this reference until <strong>super()</strong> .</li>
<li style="text-align: justify;">The same applies for ES6 sub-classes as well.</li>
<li style="text-align: justify;">The main reason of passing props parameter to <strong>super()</strong> call is to access <strong>this.props</strong> in your child constructors.</li>
<li style="text-align: justify;">The <strong>super()</strong> is a requirement, while implementing the <strong>constructor()</strong> function inside a React component.</li>
<li style="text-align: justify;">For example, <strong>super(props)</strong> would call the React.</li>
<li style="text-align: justify;">Component constructor passing in props as the argument.</li>
</ul>
<h4 id="for-example-in-passing-props">For example in <strong>Passing props</strong></h4>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markup code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markup code-embed-code">class MyComponent extends React.Component {<br/>  constructor(props) {<br/>    super(props)<br/><br/>    console.log(this.props) // prints { name: &#039;bharath&#039;, age: 23}<br/>  }<br/>}</code></pre> </div>
<p>&nbsp;</p>
<h4 id="for-example-in-not-passing-props">For example in <strong>Not passing props</strong></h4>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markup code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markup code-embed-code">class MyComponent extends React.Component {<br/>  constructor(props) {<br/>    super()<br/><br/>    console.log(this.props) // prints undefined<br/><br/>    // but props parameter is still available<br/>    console.log(props) // prints { name: &#039; bharath &#039;, age: 23 }<br/>  }<br/><br/>  render() {<br/>    // no difference outside constructor<br/>    console.log(this.props) // prints { name: &#039; bharath &#039;, age: 23 }<br/>  }<br/>}</code></pre> </div>
<ul>
<li>In The above code snippets shows that <strong>this.props</strong> is different only within the constructor.</li>
<li>It would be the same outside the constructor.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/reactjs/what-is-the-purpose-of-using-super-constructor-with-props-argument/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
