Preact: forceUpdate should take a callback

Created on 7 Dec 2016  路  4Comments  路  Source: preactjs/preact

As per the React API docs

beginner-friendly compat

Most helpful comment

Released in 8.

All 4 comments

Good catch! This is a strange one since forceUpdate() is always synchronous, so there is no real purpose to the callback. However, it should be cheap/free to add (just duplicating this line) so we're probably fine to add it.

I think it's because React queues all component updates (e.g. in setState) and so in React it may not happen synchronously.

I don't see anything in their docs about it, but maybe it's something preact is doing unnecessarily. Perhaps forceUpdate() doesn't need to be synchronous and just has to bypass shouldComponentUpdate()...

Released in 8.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

youngwind picture youngwind  路  3Comments

paulkatich picture paulkatich  路  3Comments

matuscongrady picture matuscongrady  路  3Comments

nopantsmonkey picture nopantsmonkey  路  3Comments

simonjoom picture simonjoom  路  3Comments