In each folder is a simple exercise please fork this repo and make the requested changes!
You'll need the following to work with these exercises:
- nodejs https://nodejs.org/en/
- yarn https://yarnpkg.com/lang/en/
In each folder start by running
yarn add
then after all packages are installed use
yarn start
to run the app
The app is a simple counter - please refactor the App component to use a React Hook and be a function instead of a class component
export default App = () => {
const [counter, increment, decrement] = useCounter();
return (
<div></div>
);
}
Integrate a new library into the project for selecting a date and time
library: (react datepicker)[https://reactdatepicker.com/]
Using the same date picker as Test 2 add a timer to the component to automatically add 1 second to the selected date time every second
Only start incrementing the date time AFTER they've selected a date time using the picker
hint (there is a hidden bug in this hint)
const [currentDate, updateDate] = useState<Date>();
const addSecond = () => {
if (!currentDate)
return;
updateDate(currentDate.setSeconds(currentDate.getSeconds() + 1));
}
setInterval(addSecond, 1000);
return (
<div></div>
)