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

Added content for component lifecycle method in component-lifecycle.mdx #23

Closed
wants to merge 1 commit into from

Conversation

TechGeekRahul
Copy link

📑 Description

[docs](React Component lifecycle): This PR adds a new section under the React documentation covering Component Lifecycle methods. It explains the lifecycle methods in class components (componentDidMount, componentDidUpdate, and componentWillUnmount) and provides a detailed comparison with functional components using the useEffect hook. The content includes code examples, best practices, and guidelines for handling side effects and cleanups in both class-based and functional components.

✅ Checklist

  • [ X] I have made corresponding changes that follow the style of this project.

🔗 Related Issue(s)

Closes #19

🚀 Types of changes

<! [x] Documentation update (docs for this project)

@rakshixh
Copy link
Member

Hey @TechGeekRahul did you go through the website for all the required things such as naming conventions etc? Unless those things are followed PR won't be merged, Please follow naming conventions and other contribution guidelines.

@TechGeekRahul
Copy link
Author

yes I have went through the website and followed each of the given steps and contribution guidelines.

@rakshixh
Copy link
Member

@TechGeekRahul Did you even run the project locally? I think you didn't. I can see the basic mistakes in your file; it is because there is an error. Please take time to go through the code base and do your research regarding the usage of mdx etc. Please use Astro starlight components such as tab, code etc to present the contents visually not in the md format.

Please note that everything will be reviewed.

@rakshixh
Copy link
Member

yes I have went through the website and followed each of the given steps and contribution guidelines.

Did you go through the naming conventions? Please check the name of your pull request it is not as per the guidelines.

@rakshixh rakshixh self-requested a review October 15, 2024 18:12

Example of using useEffect:

import { useEffect } from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use astro star light components


To prevent memory leaks and ensure proper resource management, it’s essential to implement cleanup functions within useEffect. The cleanup function runs before the component unmounts or before the effect runs again if dependencies change.
Example of implementing cleanup:
javascript
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please provide proper formatting. Also, note that since this doesn't include high-level code contribution we expect great content that can help all levels of developers. Therefore enhance your content with better explanation and code snippets.

The unmounting phase occurs when a component is being removed from the DOM. The relevant lifecycle method here is:
componentWillUnmount: This method is called just before a component is unmounted and destroyed. It’s typically used for cleanup tasks such as invalidating timers or canceling network requests. For example:

componentWillUnmount() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific regarding these. Include usage code of the components as well.

@TechGeekRahul
Copy link
Author

okay I will do that thanks for highlighting.

@rakshixh rakshixh added status: waiting update PR state: Waiting Update guidelines not followed Contributing guidelines are not followed labels Oct 15, 2024
javascript
useEffect(() => {
const timer = setTimeout(() => {
console.log('Timer executed');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the src\content\docs\react\codes\componentLifecycleCode folder to dump all code-related files. Please use mdx not just md. Use Astro Star Light components such as tab, code etc to present the content visually.

@rakshixh
Copy link
Member

Hey @TechGeekRahul ,
When can we expect an updated PR? Please provide an update on your work so far.

@rakshixh rakshixh added inactive State: Inactive status: closed/rejected PR state: Closed or Rejected and removed status: waiting update PR state: Waiting Update labels Oct 22, 2024
@rakshixh rakshixh closed this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidelines not followed Contributing guidelines are not followed inactive State: Inactive status: closed/rejected PR state: Closed or Rejected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Hacktoberfest]: Add content for React - Component Lifecycle
2 participants