🚨 Please create a private fork of this repository and make all PRs into your own repository
-
Try this exercise in 4 hours. 🕙
-
There are no right or wrong answers. Most likely you won't have time to finish all the tasks. We are looking for:
- Code quality ✅
- Structure ✅
- Component boundaries ✅
- Architectural decisions (e.g. why have you used this package?) ✅
-
This is a real world situation. You are allowed to use the internet!
There is a basic search feature in our app that allows search for patients based on several properties. The implementation of this feature has some problems. We're interested in two of them:
- There is a bug leading to incorrect results in some cirumstances. One simple way to cause it is typing "J" into the search after refreshing the page. It should show two search results, but nothing is displayed.
- The boundaries between the components in the implementation is convoluted.
Add a test for the search, it should cover the bug described above and any other testcases you feel are important. Feel free to use whichever testing library you think is best.
Now that we have a useful test for this component: Please refactor this component to remove the problems described above (the search bug as well as the convoluted component boundary).
Add a loading spinner to provide the user with some visual feedback while the code is waiting for a network request to complete.
Error handling in our search is a little old fashioned. Currently the errors are handled in the components and just popped up via an alert
:
// patients_search.tsx
loadPatients(sq).then(ps => onResults(ps)).catch(err => alert(err))
We want to improve this.
As our app will have more features that need error handling we want you to create a reusable hook that can be used to show a little "toast" in a corner of the screen with an error or success message.
The features of this hook should include:
- The ability to create a new toast
- Toasts should disappear after some time automatically
- Multiple toasts should not hide each other
There is a base component to use for styling in src/toast/toast.tsx
. We are not looking for you to use a toast-library here, but rather implement the high-level functionality in React yourself.
- Create a private fork of this repository
- Create a new branch in your fork
- Commit on that branch
- When you are ready to submit, create a PR back to your fork
- Add the user @heartbeat-med (https://github.com/heartbeat-med)
- We will comment on the PR
- You can either submit more code or we can discuss in the next interview 🤘
- Any questions, reach out to us!
See LICENSE file.