I have made a few simple reusable react components and wanted to know the correct way to include a dependency to react in my package.json for publishing with npm.
I am currently doing this:
Assuming my component will use the most recent version of react and I have tested and it works with that version. e.g. 0.13.3
For reusable components:
reactdependency both in
peerDependencies specifies which version(s) of React your reusable component supports/requires. Currently this also adds React to the list of modules to be installed, but packages listed in
peerDependencies will not be installed automatically as of npm v3.
devDepedencies ensures React will be installed when you run
npm install while developing your component, or when running tests on Travis or similar.
dependencies will cause multiple versions of React to be installed if somebody uses your component but has a different version of React in their own
package.json - having multiple versions of React not only bloats the build, but also causes errors when different versions try to interact.