<div class="question-left">How do you invoke setDone only when component mounts, using hooks?</div>
<div class="question-right">
<div class="question-right">

function MyComponent(props) {
const [done, setDone] = useState(false);

return &lt;h1&gt;Done: {done}&lt;/h1&gt;;
}
<p class=" language-javascript"><code class=" language-javascript"><span class="token keyword">return</span> <span class="token operator">&lt;</span>h1<span class="token operator">&gt;</span>Done<span class="token punctuation">:</span> <span class="token punctuation">{</span>done<span class="token punctuation">}</span><span class="token operator">&lt;</span><span class="token operator">/</span>h1<span class="token operator">&gt;</span><span class="token punctuation">;</span></code></p>

<p class=" language-javascript"><code class=" language-javascript">
<span class="token punctuation">}</span></code>

</div>
</div>