Open henrynguyen6677 opened 1 year ago
Hi @henrynguyen6677 ,
Final result: ✅ passed
localStorage
. This way, the user's theme preference can be remembered and applied consistently across sessions.Searching the book name should support the case-sensitive.
Should validate input before adding a new book
This process should be refactored into a pure function to obtain the initial data, and a state should be used to store the book data instead of the current approach. This change is necessary because React cannot automatically re-render based on changes in localStorage. And use with localStorage
operations should be handled with error handlings too.
createContext
function should be an object with properties, not types. You should provide an initial state object with the shape you want for your context.Example you can create context like this:
import { createContext } from "react";
const noop = () => {}
export const BookRowsContext = createContext({
rows: [],
setRows: noop,
setStart: noop,
start: 1,
deleteRow: {},
});
.
start
-> page
rows
-> books
AddBookOverlay
-> AddBookFormModal
DeleteBookOverlay
-> DeleteBookModal
@chinhld12 Thank you for your feedback. I have a question about ticket Standard use of React component & state
. What is the standard to follow?
@henrynguyen6677
To enhance your codebase, you should address several issues:
Avoid directly mutating the state in your code. Instead, use React's state management mechanisms state hooks (useState and useReducer) to update state values in an immutable manner.
Ensure that you are using the Context API correctly. It's important to follow the recommended patterns for creating and consuming contexts in React.
Review your usage of GlobalData
(Vanilla JS) alongside the Context API.
Eliminate redundant code to improve code maintainability and readability. Look for opportunities to refactor and reuse code blocks where possible.
...
You can see more here:
@chinhld12 Please take your time to review this PR #4 for refactor of assignment 2. With some main improvements:
Add capture: Add link: https://df-frontend-2023-ojhr.vercel.app/
Thank you for your efforts
Looks better than the previous one but still has some bugs:
Should automatically change to page 1 when page 2 is empty after deleting all book records
The Page button should be available for the user to click on the padding area too, not only the number
Since these are functional methods for handling actions, you should use camelCase instead of PascalCase https://github.com/henrynguyen6677/df-frontend-2023/blob/edf3ac0d696ac4d911702ee15ad84c6427a81910/assignment-2/src/utils/localstore.js#L6-L20
Typo ToogleComponent
-> ThemeToggleInput
Seem you have not fixed this: https://github.com/henrynguyen6677/df-frontend-2023/blob/edf3ac0d696ac4d911702ee15ad84c6427a81910/assignment-2/src/contexts/books.context.js#L3-L14
@chinhld12 Thank you for your feedback. I have some updates on it. Please take your time to review this PR #11 for refactoring assignment 2.
Improvements:
Add video:
Link: https://df-frontend-2023-ojhr.vercel.app/
Thank you for your efforts
https://df-frontend-2023-ojhr.vercel.app/