Closed AnnaSolovykh closed 3 months ago
After reviewing the code in the following files: ResetPassword.jsx, Signin.jsx, RegisterForm.jsx, Register.jsx, EmailVerify.jsx, ForgetPassword.jsx, components do not use setState or any state update function as a prop. The code adheres to the best practice of avoiding passing setState functions as props, ensuring proper encapsulation and maintainability of the component.
These are those I could find now quickly. Please check the whole codebase to ensure you find all of them. setState - is a general name because it is used for setting the state. Other namings depending on the purpose are used in the codebase.
@Nassimancer
Let's change the strategy of searching, @Nassimancer ! We will use regex for that. I have updated the instructions.
Please make sure to the the resources I attached about lifting the state. You can, of course, use some others too, first look into it in details.
https://www.robinwieruch.de/react-lift-state/ https://www.robinwieruch.de/react-derive-state-props/
I will add up more links.
Description
Refactor instances where
setState
is used as a prop in the codebase to ensure best practices and maintain code quality.Context
Using
setState
as a prop can lead to various issues, including unintended side effects, difficulty in debugging, and poor component encapsulation. The goal is to locate all instances wheresetState
is passed as a prop and refactor the code to avoid this pattern.Requirements
setState
as a Prop: Search the codebase for any occurrences wheresetState
is being passed as a prop.setState
as a prop.setState
as a prop, such as using callback functions or context API.Steps to Resolve
Search for Usage:
set[A-Z][a-zA-Z]*\s*=\{
to find all occurrences. Click on the .* icon to the right of the search input box to enable regex search.Refactor Example:
Test Changes: Ensure all refactored components are tested to verify that state updates work correctly without passing
setState
as a prop.Additional Resources