moti: Uncaught TypeError: createAnimatedComponent is not a function

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Screen Shot 2022-08-22 at 17 27 53

Expected Behavior

Stable work on all platform: web, ios, android

Steps To Reproduce

Screen Shot 2022-08-22 at 17 32 47

Versions

- Moti: 0.19.0-alpha.6
- Reanimated: ~2.9.1
- React Native: 0.69.4

Screenshots

No response

Reproduction

https://snack.expo.dev/@makhataibar/eaa888?platform=web

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

@crutch12 thank you for the details

@rafakwolf

I’ve tested your configs with my project - and it works now!

Your babel.config.js works perfectly, it solves the problem:

// babel.config.js
module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      [
        'module-resolver',
        {
          extensions: ['.js', '.ts', '.tsx'],
          alias: {
            react: './node_modules/react',
            'react-native': './node_modules/react-native-web',
          },
        },
      ],
      '@babel/plugin-proposal-export-namespace-from',
      'react-native-reanimated/plugin'
    ]
  };
};

Here is the dramatic difference:

// babel.config.js
plugins: [
  [
    'module-resolver',
    {
      extensions: ['.js', '.ts', '.tsx'],
      alias: {
        'react': './node_modules/react',
        'react-native': './node_modules/react-native-web',
      },
    },
  ],
  '@babel/plugin-proposal-export-namespace-from',
  // ...
],

My previous babel.config.js:

// babel.config.js
module.exports = function (api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      'react-native-reanimated/plugin',
    ],
  };
};

Here is my webpack.config.js (I didn’t change it, it works fine with new babel.config.js):

// webpack.config.js
const createExpoWebpackConfigAsync = require('@expo/webpack-config');

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(
    {
      ...env,
      babel: {
        dangerouslyAddModulePathsToTranspile: ['moti', '@motify'],
      },
    },
    argv
  );

  config.resolve.alias['framer-motion'] = 'framer-motion/dist/framer-motion';

  return config;
}

So I think that adding react-native-reanimated in dangerouslyAddModulePathsToTranspile section is unnecessary

@crutch12 babel.config and webpack.config

Expo uses --legacy-peer-deps by default

Do you mean with expo install?