• About WordPress
    • WordPress.org
    • Documentation
    • Learn WordPress
    • Support
    • Feedback
  • Log In
  • Register
Skip to main content
RxHarun
Login / Register Login/Signup
  • Health (A – Z)
  • Drugs (A – Z)
  • Rx Cancer (A – Z)
  • Rx Neurology (A – Z)
  • Rx Urology
  • Rx Lab Test (A – Z)
  • Rx Shop (A – Z)
  • Rx iT World
  • Rx Foundation
...

AJAX requests should go in the componentDidMount lifecycle event.

Dr. Harun Ar Rashid, MD - Arthritis, Bones, Joints Pain, Trauma, and Internal Medicine Specialist Dr. Harun Ar Rashid, MD - Arthritis, Bones, Joints Pain, Trauma, and Internal Medicine Specialist
4 Views
PHP, JS, CSS, Python, and Machine Learning Technology

Fiber, the new React reconciliation algorithm, has the ability to start and stop rendering as needed for performance benefits. One of the trade-offs of this is that componentWillMount, the other lifecycle event where it might make sense to make an AJAX request, will be “non-deterministic”. What this means is that React may start calling componentWillMount at various times whenever it feels like it needs to. This would obviously be a bad formula for AJAX requests.

You can’t guarantee the AJAX request won’t resolve before the component mounts. If it did, that would mean that you’d be trying to setState on an unmounted component, which not only won’t work, but React will yell at you for. Doing AJAX in componentDidMount will guarantee that there’s a component to update.

SaveSavedRemoved 0
AJAX requests should go in the componentDidMount lifecycle event.
Previous

React lifecycle methods

AJAX requests should go in the componentDidMount lifecycle event.
Next

What is Shallow Comparison from Official dox

Related Articles
Added to wishlistRemoved from wishlist 0
How To Speed Up a WordPress (WP) Web Site

How To Speed Up a WordPress (WP) Web Site

Added to wishlistRemoved from wishlist 0
JavaScript Frameworks and Libraries List

JavaScript Frameworks and Libraries List

Added to wishlistRemoved from wishlist 0
Types of Linux

Types of Linux

Added to wishlistRemoved from wishlist 0
User Agents for Web Scraping

User Agents for Web Scraping

Sign up for our free Good Health Newsletter!

We don’t spam! Read our privacy policy for more info.

Check your inbox or spam folder to confirm your subscription.

About Rehub

This demo site is only for demonstration purposes. All images are copyrighted to their respective owners. All content cited is derived from their respective sources. Credits

How to Make Custom Footer Area Via Page Builder

test@test.com
3800003030

About Rehub

Re:Hub is modern all in one price comparison and review theme with best solutions for affiliate marketing. This demo site is only for demonstration purposes. All images are copyrighted to their respective owners. All content cited is derived from their respective sources.

How to Make Custom Footer Area Via Page Builder

Terms and Conditions of Use Privacy Policy Cookie Policy Editorial Policy Advertising Policy Correction Policy
Contact us About us Newsletter Career Sitemap
Advertise with us
Rx Team
  • Editorial Board Members
  • Review Board Member
  • Team Rxharun
  • Web Developers Team
  • Guest Posts and Sponsored Posts
  • Request for Board Member
Authority
  • Contact us
  • About us
  • Newsletter
  • Career
  • Sitemap
For customers
  • First link
  • Second Link
  • Third link
  • Fourth link
For vendors
  • First link
  • Second Link
  • Third link
  • Fourth link

Mobile Application

Follow Rxharun on Social Media
Sign Up for Weekly Newsletter

Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius.

Custom links
  • First link
  • Second Link
  • Third link
  • Fourth link
Custom section
  • First link
  • Second Link
  • Third link
  • Fourth link
RxHarun
Logo
Register New Account
Already have an account? Login
Log In
Lost Password?
Don't have an account? Sign Up

RxHarun

AI Chat Bot

Dorian

Hey, how can I help you today?

Powered by Elementor

Click to start chat