Closed alphazee09 closed 3 months ago
@alphazee09 is attempting to deploy a commit to the dottle's projects Team on Vercel.
A member of the Team first needs to authorize it.
Hey There ! Thank you for the feedback. I appreciate you pointing out these issues.
Export and Hook Not Being Called:
Handling Invalid IDs in deleteArea
:
deleteArea
, it won’t affect the state. I’ll implement additional checks to ensure that invalid IDs are handled gracefully or log a warning if an attempt is made to delete a non-existent area.Adding Existing Areas:
addArea
function to ensure it handles new areas correctly and that existing ones are managed based on the undo/redo functionality. I’ll also check if the data is correctly passed down from undo or redo.Thank You Dude
I appreciate the effort, brother. If you're planning to make another PR for this, don't worry about it.
Refactor AreasContextProvider: Add context export, custom hook, PropTypes validation, and error handling
**AreasContext**
export and createduseAreasContext
custom hook for safer and easier context access.**PropTypes**
to validatechildren
prop inAreasContextProvider
component.**addArea**
function by breaking it intoaddExistingArea
andaddNewArea
for improved readability and maintainability. - Added error handling indeleteArea
function to prevent operations with invalid IDs. - Extracted logic to clear selected element into a separate function for better separation of concerns. - Ensured proper default export forAreasContextProvider
to facilitate correct imports.Enhance TypesContext and useFullscreen with improvements for robustness and usability
Changes to TypesContextProvider:
Added TypeScript Type Annotations:
Improved History Management:
Updated Add and Delete Methods:
Adjusted State Management:
Changes to useFullscreen Hook:
Replaced useEventListener with Native DOM API:
useEventListener
todocument.addEventListener
for clearer control over event listener lifecycle and to avoid potential issues with third-party hooks.Utilized useEffect for Cleanup:
useEffect
for proper attachment and cleanup, preventing potential memory leaks and ensuring efficient event handling.Improved State Initialization:
Why These Changes:
useEffect
ensures that event listeners are properly managed and cleaned up, reducing the risk of memory leaks and improving performance.These changes improve the robustness, maintainability, and performance of the
TypesContext
anduseFullscreen
components.