Build a React app that displays a counter starting at 0.
Requirements:
- Show the text
You clicked {count} times. - Render a button labeled
Click Me. - When the button is clicked, increase the counter by
1. - Use React state to store and update the count.
- Include a navbar component with the title
React App.
The component should use the provided h8k-navbar component. The counter text should have data-testid="output", and the button should have data-testid="add-button".
这道题是一个典型的 React 状态管理入门题,核心是用 useState 保存计数器 count,并在按钮点击时通过 setCount(count + 1) 更新状态。页面需要渲染一个导航栏和中间的计数文本“You clicked {count} times”,同时按钮文案固定为“Click Me”。实现时重点关注组件结构、事件绑定以及测试属性 data-testid 的准确填写,属于基础但很常见的前端 OA 面试题。