Skip to content
This repository was archived by the owner on Apr 9, 2020. It is now read-only.
This repository was archived by the owner on Apr 9, 2020. It is now read-only.

Freeze/continual-reloading when Component is aliased #82

Open
@Venryx

Description

@Venryx

I have a React Native project that uses hot-reloading. (Repo: https://github.com/Venryx/LucidLink)

I wrote a class named BaseComponent which extends the React.Component class.

However, when I do so, hot-reloading breaks. When I make a change within the render function of a component deriving from that BaseComponent class, react native tries to hot-reload, but ends up freezing the UI because it enters a loop of continually trying to update itself.

The Android logcat shows this (after a change) until I kill the app:

12-23 04:29:16.451 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI
12-23 04:29:16.462 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI
12-23 04:29:16.472 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI
12-23 04:29:16.482 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI
12-23 04:29:16.493 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI
12-23 04:29:16.504 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI
12-23 04:29:16.515 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI
12-23 04:29:16.527 17424-17452/com.lucidlink I/ReactNativeJS: [React Transform HMR] Patching LucidLinkUI

I thought I might have added something to my BaseComponent class that broke hot-reloading. But no. I removed all its code, and just had it extend Component (eg: class BaseComponent extends Component {}), and the issue remained.

I then thought, maybe some part checks whether the class name is "Component", and fails if it doesn't.

Not even that is true. I tried the following:

Before (hot-reloading works):

class MyComponent extends Component {
    ...
}

After (hot-reloading fails):

var AliasOfComponent = Component;
class MyComponent extends AliasOfComponent {
    ...
}

Yes, simply changing the variable name causes it to break! That doesn't make any sense unless it's somehow part of the compile process. (since all values referenced are exactly the same)

Any idea what's causing this, or what area of the react-native ecosystem to look in for the source of this bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions