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

Should componentDidMount optionally return a promise? #16280

Closed
patsplat opened this issue Aug 2, 2019 · 2 comments
Closed

Should componentDidMount optionally return a promise? #16280

patsplat opened this issue Aug 2, 2019 · 2 comments

Comments

@patsplat
Copy link

patsplat commented Aug 2, 2019

Do you want to request a feature or report a bug?

Feature Request

What is the current behavior?

Currently, componentDidMount returns nothing. It is the recommended lifecycle hook for performing async operations. It is necessary to create wrapper functions returning a promise to test such operations (#14687).

What is the expected behavior?

Unlike the suggestion in #1739 etc do not recommending changing any rendering semantics. Simply allow a promise to be returned so that testing does not require boilerplate.

@kambleaa007
Copy link

Do anybody knows steps to solve this feature, im ready to work on it

@patsplat
Copy link
Author

patsplat commented Aug 7, 2019

Have been discussing and exploring this feature in my applications.

Am leaning towards making this more a documentation change, ie updating the website to illustrate patterns for retaining and testing a ref to a Promise.

If React doesn't use the promise, can see a pragmatic argument against changing the signature of the method.

Downstream libraries such as linting etc would have to be updated, which seems a high cost.

@patsplat patsplat closed this as completed Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants