Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor every react component to use react-hooks #58

Closed
4 tasks
razvanilin opened this issue Oct 14, 2020 · 3 comments
Closed
4 tasks

Refactor every react component to use react-hooks #58

razvanilin opened this issue Oct 14, 2020 · 3 comments
Labels
good first issue Good for newcomers hacktoberfest Tasks suitable for the Hacktoberfest event no-issue-activity refactoring

Comments

@razvanilin
Copy link
Member

razvanilin commented Oct 14, 2020

How to contribute to this issue:

  • Scroll down below to check the existing PRs so you don't open a PR for a component waiting for review
  • Refactor components based on the description below - also check the guidelines for PRs
  • Reference this issue with #58 in the PR description so we can track which components are being worked on
  • Open one PR per component

Examples of final results:

The refactoring should address the following:

class components => functional components

class CoolComponent {
  constructor(props) {}
}

// to

function CoolComponent(props) {
  // deconstruct all the props here, at the beginning
  const { someProp, anotherOne } = props;
}

Lifecycle methods switched to useEffect

componentDidMount()

// to

useEffect(() => {}, []);
componentDidUnmount()

// to

useEffect(() => {
  return () => {
    // do stuff here when closing down the component
  }
}, []);
componentDidUpdate()

// to

useEffect(() => {}, [someProp]);
// someProp should be the prop or multiple props that the component should watch for

Internal this.state => useState

this.state = {
  loading: true,
};

// to

const [loading, setLoading] = useState(true);

All previous class methods should now be constant variables

class CoolComponent {
  _someMethod = () => {}
}

// to

function CoolComponent() {
  const _someMethod = () => {};
}
@HunainHumail
Copy link

I would like to work on this issue to convert the class components to functional components.
Please assign me this issue
Thanks

@razvanilin
Copy link
Member Author

I would like to work on this issue to convert the class components to functional components.
Please assign me this issue
Thanks

Hi, thanks for your interest. Please read the issue carefully. This is not to be assigned since it will need multiple PRs from multiple people. Others already created PRs (as you can see above)

Copy link

Marked as stale because of inactivity. Feel free to comment if you still have this issue.

@github-actions github-actions bot closed this as completed Mar 8, 2024
@razvanilin razvanilin moved this from In progress to Done in Chartbrew Devlog Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest Tasks suitable for the Hacktoberfest event no-issue-activity refactoring
Projects
Development

No branches or pull requests

2 participants