I have a package on NPM that is using React version 15 as peer dependency. However, I want it to stop from throwing warnings for users that upgraded their React version. How do I make package support both version 15 and 16?
"peerDependencies": {
"react-dom": "^15.0.0"
},
which is the most convenient way to deal with these?
Is "*15.0.0"
good enough?
What about:
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0"
}
To address a range you can use following notation :
"peerDependencies": {
"react-dom": "15 - 16"
}
Makes it really easy to define a range as well.
You can test them out here : https://semver.npmjs.com/
Just checked some other packages on GitHub how they do it.
Using *
didn't work out for me and therefore seems like bad practice anyway.
Better solution:
"peerDependencies": {
"react": ">=0.14.0 <= 16",
"react-dom": ">=0.14.0 <= 16"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.