Here is sample code that is not by far ideal.
- Refactor code to production-grade quality.
- Find and describe bugs and issues.
- Add styling by your choice. (You can add styling library)
- Demonstrate connection to backend API.
- Add Todo detail page (add routing to app, use context api for state managment from fetch todos to render todos and detail)
- Todo component has defined shouldComponentUpdate lifecycle, but it can be done better, adjust it
- Optional: rewrite Todo component to FC (choose if you want, prepare explanation)
-
To be able to run this app, I used
npx create-react-app notino-react-app --template typescript
as a quickstart, formatting code using airbnb -
Bugs and issues in App.tsx: useEffect fires again and again after each change due to missing an array of dependencies instead of once after first render (componentDidMount) calling set state in for loop component Todo has no key (tasks mapping) repeating definition of Todo type
Bugs and issues in Todo.tsx: shouldComponentUpdate is implemented already in React.PureComponent, it is possible to achieve the same with React.memo or useMemo routing implemented by react-router, window.location.href should be absolute, but causes a complete reload
-
Used simple scss import
-
Used Mock API serving dummy JSON in combination with superagent
-
404 not implemented, redirected to homepage
-
Can be achieved by React.PureComponent which is already implementing shouldComponentUpdate, or by memoization
-
Todo component is stateless and does not use any lifecycle method