Reactjs.org: Are hooks synchronous?

Created on 17 Feb 2020  路  4Comments  路  Source: reactjs/reactjs.org

I've searched in the docs but didn't found this information. So, hooks are synchronous or asynchronous?

Most helpful comment

you cant define a hook as async because they are not supposed to return a promise. If you do it will result in race conditions. So instead write async function inside the hook and then call it.

All 4 comments

@gajomon hooks are synchronous

Alright, but where is this information from?

you cant define a hook as async because they are not supposed to return a promise. If you do it will result in race conditions. So instead write async function inside the hook and then call it.

Alright, I've tried it and you're right, hooks doesn't returned a promise. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

franciscop-invast picture franciscop-invast  路  6Comments

grundmanise picture grundmanise  路  5Comments

andresmatasuarez picture andresmatasuarez  路  5Comments

mbrowne picture mbrowne  路  5Comments

tajo picture tajo  路  4Comments