redradix / react-children-xt

Count and map over React children flattening fragments and not taking into account elements that won't be rendered such as `undefined` or `null`
0 stars 0 forks source link

Evaluate specifying React in package.json's peerDependencies instead of failing at runtime #1

Open roberto-red opened 1 year ago

roberto-red commented 1 year ago

This package is dependent of React, but its package.json does not mention React anywhere. Instead, the code uses a dynamic CommonJS require() in order to be able to show an error when React is not installed.

This may be solved with package.json's peerDependencies, which also allows us to specify which React version the code is compatible with. Here is an in-depth explanation from the node.js blog:

https://nodejs.org/en/blog/npm/peer-dependencies

I've personally never used it before and there might be some pitfalls, so this change will need to be thoroughtly evaluated first.

acontreras89 commented 1 year ago

+1

This is what I had in mind when thinking about publishing these utilities as a standalone package.