Sobes.tech
Back to tasks
Junior — Senior
105

Обнаружение багов в React‑компоненте с хуками

Get help with live coding in real time with Sobes Copilot
Task condition

Найдите и исправьте ошибки в следующем React‑компоненте, использующем хук useState.

import React, { useState } from 'react';

export const MyComponent = ({ title }) => {
  const [count, setCount] = useState(0);

  function incrementCount() {
    count += 1;
  }

  return (
    <div>
      <h1>{props.title}</h1>
      <p>Count: {count}</p>
      <button onClick={incrementCount()}>Click me!</button>
      <p>{props.subtitle}</p>
    </div>
  );
};