react-puer
Version:
A small function to create Render Props.
2 lines (1 loc) • 1.09 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e["react-puer"]=n()}(this,function(){"use strict";var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=process.env.NODE_ENV,o=function(e){return"function"==typeof e},t=function(e,n){if(e)throw new Error("[react-puer]: "+n)};return function(){var r,u,i,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},f=c.children,d=c.render,p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t(!f&&!d,"You need pass an object with a `children` or `render` property"),t(f&&!o(f),"`children` must be a function"),t(d&&!o(d),"`render` must be a function"),t(p&&!("object"===(void 0===(r=p)?"undefined":e(r))),"`props` must be an object"),u="production"!==n&&o(f)&&o(d),i="You can't use children and render, so only children will be used",u&&console.warn("[react-puer]: "+i),(o(f)?f:d)(p)}});