How to avoid `loaded two copies of React` error when developing an external component?

前端 未结 9 1653
无人共我
无人共我 2020-12-28 14:05

I am developing an external component (let\'s say my-component, which I link to the project with npm link (as it is in process and I need the packa

9条回答
  •  醉话见心
    2020-12-28 14:43

    Fixed it by adding react-dom as an alias to my webpack config

    alias: {
    
        react$: require.resolve(path.join(constants.NODE_MODULES_DIR, 'react')),
        'react-dom': require.resolve(path.join(constants.NODE_MODULES_DIR, 'react-dom'))
    
    }
    

提交回复
热议问题