Skip to content

Instantly share code, notes, and snippets.

@mistakster
Last active December 10, 2024 12:31
Show Gist options
  • Save mistakster/d84d8f7e931fe5e19c53ea2b82b89f41 to your computer and use it in GitHub Desktop.
Save mistakster/d84d8f7e931fe5e19c53ea2b82b89f41 to your computer and use it in GitHub Desktop.
A case for interviewing a React developer
import { useState } from 'react';
const Page = () => {
const [value, setValue] = useState(0);
return (
<Counter
value={value}
increase={() => setValue(value + 1)}
/>
);
};
const Counter = (props) => {
const { value, increase } = props;
return (
<div>
<span>{value}</span>
{' '}
<button onClick={increase}>+1</button>
</div>
);
};
export default Page;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment