Skip to content

Vite build breaks configureRemoteControl #201

@adrianbunea

Description

@adrianbunea

I have a React Native app, now I am trying to build for web with react-native-web. The vite dev server serves the app and it works ok, navigation works correctly.

However, if I build with vite, and serve it using a simple nginx server to test, I get a warning like "you forgot to configure remote control, make sure you called configureRemoteControl".

My entrypoint is like this

console.log('configuring remote control');

SpatialNavigation.configureRemoteControl({
  remoteControlSubscriber: (callback) => {
    console.log('[CONFIG] Subscriber configured');
    const mapping: { [key in SupportedKeys]: Directions } = {
      [SupportedKeys.Right]: Directions.RIGHT,
      [SupportedKeys.Left]: Directions.LEFT,
      [SupportedKeys.Up]: Directions.UP,
      [SupportedKeys.Down]: Directions.DOWN,
      [SupportedKeys.Enter]: Directions.ENTER,
      [SupportedKeys.LongEnter]: Directions.LONG_ENTER
    };

    const remoteControlListener = (keyEvent: SupportedKeys) => {
      callback(mapping[keyEvent]);
      return false;
    };

    return RemoteControlManager.addKeydownListener(remoteControlListener);
  },

  remoteControlUnsubscriber: (remoteControlListener) => {
    console.log('[CONFIG] Unsubscriber configured');
    RemoteControlManager.removeKeydownListener(remoteControlListener);
  }
});

console.log('finished configuring');

AppRegistry.registerComponent(appName, () => App);
AppRegistry.runApplication(appName, {
  rootTag: document.getElementById('app-root')
});

I have a hard time debugging the bundled and obfuscated build, but from what I noticed, the remoteControlSubscriber and remoteControlUnsubscriber are
being assigned internally when SpatialNavigation.configureRemoteControl is called, but when the code for checking if configuration is done properly, remoteControlUnsubscriber is undefined which causes the warning to fire.

As far as I can tell, I don't have duplicated instances of SpatialNavigation, at least my code doesn't suggest it.

I know there isn't much info, I am just writing this to see if there has been such a problem or there is a gotcha I missed.

I am using vite v6.2

Metadata

Metadata

Labels

Status:Check ResultA fix has been deployed and user check is needed

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions