Skip to content

use-subscription causes UI tearing in some random cases #16396

@milankinen

Description

@milankinen

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

Bug

What is the current behavior?

Referring to this twitter conversation, it seems that use-subscription can cause "UI tearing" in some random cases due to a (possible) race condition w.r.t. the combination of subscribe and getCurrentValue in internal usage.

Here is a minimalistic application demonstrating the behaviour: https://github.com/milankinen/use-subscription-tearing-demo

What is the expected behavior?

I'd expect counters in the example application to always render same number.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Tested React version: 16.9.0 (haven't tested with older ones)
OS: OSX 10.14.6
Hardware: MacBook Pro (Retina, 15-inch, Mid 2015) 2.8 GHz Intel Core i7 & 16GB RAM
Browser: Chrome Version 76.0.3809.100 (Official Build) (64-bit)

@bvaughn

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions