#Webpack, babel loader - "Spread children are not supported in React"

3 messages · Page 1 of 1 (latest)

tidal cradle
#

Hi, been attempting to build my next application to support older browsers - some of our code uses a spread for components. We're using the @babel/preset-react preset

In our next js config, we still error with Spread children are not supported in React. on build.

( It's erroring on a component with a usage like this: {...Components} )

I'm using webpack like the following in our nextjs config:

webpack(config) {
  config.module.rules.push({
    test: /\.(js|tsx|ts)$/i,
    exclude: /node_modules/,
    use: {
      loader: 'babel-loader',
      options: {
        presets: [
          '@babel/preset-env',
          'next/babel',
          '@babel/preset-typescript',
          '@babel/preset-react',
          '@babel/preset-flow',
        ],
        plugins: [
          ['@babel/plugin-transform-react-jsx'],
          ['@babel/plugin-proposal-optional-chaining'],
          ['@babel/plugin-transform-spread'],
        ],
      },
    },
  });

If anyone has any expertise on webpack with this - that would be amazing

storm kelpBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

loud knot