title: Prevent multiple versions of React (while creating npm package)
body: <p>I intend to create an npm package (<a href="https://www.npmjs.com/package/recharts-candlestick" rel="nofollow noreferrer">recharts-candlestick</a>). The only dependency my package has is Recharts. I have created the package, used Webpack to build it and tested the package locally using npm link. This works when I do NOT use Recharts, but as soon as I have Recharts as a peer dependency I get an error message (<a href="https://reactjs.org/docs/error-decoder.html/?invariant=321" rel="nofollow noreferrer">https://reactjs.org/docs/error-decoder.html/?invariant=321</a>). I think I am having this issue because I have multiple versions of react:</p>
  <pre><code>$ npm ls react
  test@0.1.0 C:\path_to_project
  ├─┬ react-dom@17.0.2
  │ └── react@17.0.2 deduped
  ├─┬ react-scripts@5.0.0
  │ └── react@17.0.2 deduped
  ├── react@17.0.2
  └─┬ recharts-candlestick@1.0.3
    ├── react@17.0.2 deduped
    └─┬ recharts@2.1.9
      ├─┬ react-resize-detector@6.7.8
      │ └── react@17.0.2 deduped
      ├─┬ react-smooth@2.0.0
      │ ├─┬ react-transition-group@2.9.0
      │ │ └── react@17.0.2 deduped
      │ └── react@17.0.2 deduped
      └── react@17.0.2 deduped
  </code></pre>
  <p>I have tried fixing the duplicate react packages locally by linking the react version in the package to the react package of the project I am testing the package in (<a href="https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react" rel="nofollow noreferrer">https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react</a>). I would however suspect that with the current setup there would not be any errors anyway because the other react versions are all deduped. The source code for the package can be found here: <a href="https://github.com/jobdenotter/candlestick-chart" rel="nofollow noreferrer">https://github.com/jobdenotter/candlestick-chart</a>. The package.json of the package code is:</p>
  <pre><code>  &quot;name&quot;: &quot;my-package&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;build/index.js&quot;,
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;,
      &quot;build&quot;: &quot;webpack&quot;,
      &quot;start&quot;: &quot;webpack --watch&quot;
    },
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;dependencies&quot;: {
      &quot;@babel/preset-env&quot;: &quot;^7.16.11&quot;,
      &quot;@babel/preset-react&quot;: &quot;^7.16.7&quot;,
      &quot;webpack&quot;: &quot;^5.72.0&quot;
    },
    &quot;peerDependencies&quot;: {
      &quot;react&quot;: &quot;^17.0.0&quot;,
      &quot;react-dom&quot;: &quot;^17.0.0&quot;,
      &quot;recharts&quot;: &quot;^2.1.9&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;babel-cli&quot;: &quot;^6.26.0&quot;,
      &quot;babel-core&quot;: &quot;^6.26.3&quot;,
      &quot;babel-loader&quot;: &quot;^8.2.4&quot;,
      &quot;babel-plugin-transform-object-rest-spread&quot;: &quot;^6.26.0&quot;,
      &quot;babel-plugin-transform-react-jsx&quot;: &quot;^6.24.1&quot;,
      &quot;babel-preset-env&quot;: &quot;^1.7.0&quot;,
      &quot;webpack-cli&quot;: &quot;^4.9.2&quot;
    }
  }
  </code></pre>