react-native-animatable icon indicating copy to clipboard operation
react-native-animatable copied to clipboard

__esModule is being included in the initial animation definitons

Open jesster2k10 opened this issue 5 years ago • 1 comments

For some reason, { "__esModule": true } is being included in the array of animation definitions pre-installed in the library.

This causes the app to crash without fail, throwing this error: Animation definitions must have at least two values. since a boolean would have "only one value"

I found to fix it you could add a simple if clause to make sure the definitionName does not equal __esModule in the initializeRegistryWithDefinitions function in registry.js

So it would look something like this:

export function initializeRegistryWithDefinitions(definitions) {
  Object.keys(definitions).forEach(animationName => {
    if (animationName !== '__esModule') {
      registerAnimation(
        animationName,
        createAnimation(definitions[animationName]),
      );
    }
  });
}

This works, but it seems a little hacky. I think the way the definitions are being imported/exported as esModules definitely has something to do with it.

jesster2k10 avatar May 19 '19 08:05 jesster2k10

For some reason, { "__esModule": true } is being included in the array of animation definitions pre-installed in the library.

This causes the app to crash without fail, throwing this error: Animation definitions must have at least two values. since a boolean would have "only one value"

I found to fix it you could add a simple if clause to make sure the definitionName does not equal __esModule in the initializeRegistryWithDefinitions function in registry.js

So it would look something like this:

export function initializeRegistryWithDefinitions(definitions) {
  Object.keys(definitions).forEach(animationName => {
    if (animationName !== '__esModule') {
      registerAnimation(
        animationName,
        createAnimation(definitions[animationName]),
      );
    }
  });
}

This works, but it seems a little hacky. I think the way the definitions are being imported/exported as esModules definitely has something to do with it.

I got same error in 2022 but still work this hacks.

react 17.0.2 react-native 0.67.2 react-native-modal 13.0.0 <-- cause error.

freezen82 avatar Feb 22 '22 12:02 freezen82