Question about react-redux npm package 'peerDependencies'

564 Views Asked by At

This is the package.json

  "peerDependencies": {
    "react": "^16.8.3 || ^17",
    "redux": "^2.0.0 || ^3.0.0 || ^4.0.0-0"
  },
  "devDependencies": {
    "react": "^16.14.0",
    "redux": "^4.0.5",
  }

Generally if the package (usually the src directory) depends on 'react', which react-redux do, we should put the dependency to 'dependencies'. My understanding that react-redux doesn't do that is because they don't want to let npm install to install it, instead, they want to just let npm to throw a warning (npm v7 will install it again) based on 'peerDependencies' tag. With "react" in 'devDependencies' tag, the compile can still work.

First I hope someone can confirm my understanding, or let me know what it should be.

My question is, since 'react-redux' can work with redux@2, why in 'devDependencies' it doesn't use redux@2? The risk is that how can we make sure the code is safe with redux@2 while we work and test using redux@4?

Thanks.

0

There are 0 best solutions below