@donnikitos/react-usepromise
Advanced tools
Comparing version 1.1.3 to 1.1.4
25
index.js
/*! | ||
Copyright (c) 2020 Nikita 'donnikitos' Nitichevski. | ||
Licensed under the MIT License (MIT), see | ||
https://github.com/donnikitos/promiseState | ||
https://github.com/donnikitos/react-usePromise | ||
*/ | ||
@@ -12,4 +12,4 @@ import React from 'react'; | ||
let Comp = $r.default ?? $r; | ||
for (const k of $resolveModule.split('.')) { | ||
if (!Comp[k]) | ||
for(const k of $resolveModule.split('.')) { | ||
if(!Comp[k]) | ||
break; | ||
@@ -19,5 +19,5 @@ | ||
} | ||
if (typeof Comp == 'function') { | ||
if(typeof Comp == 'function') { | ||
const rElem = React.createElement(Comp); | ||
if (React.isValidElement(rElem)) | ||
if(React.isValidElement(rElem)) | ||
Comp = rElem; | ||
@@ -38,5 +38,2 @@ } | ||
} | ||
export default usePromiseStateFN; | ||
export const usePromiseState = usePromiseStateFN; | ||
export const usePromise = usePromiseStateFN; | ||
@@ -46,2 +43,14 @@ function updateStateFN($stateSetter) { | ||
} | ||
if(typeof module !== 'undefined' && module.exports) { | ||
module.exports = { | ||
usePromiseState: usePromiseStateFN, | ||
usePromise: usePromiseStateFN, | ||
updateState: updateStateFN | ||
}; | ||
} | ||
export default usePromiseStateFN; | ||
export const usePromiseState = usePromiseStateFN; | ||
export const usePromise = usePromiseStateFN; | ||
export const updateState = updateStateFN; |
{ | ||
"name": "@donnikitos/react-usepromise", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Use promisises and asynchronous component loading hook for React.js", | ||
@@ -24,3 +24,5 @@ "main": "index.js", | ||
"components", | ||
"functional" | ||
"functional", | ||
"ES6", | ||
"CommonJS" | ||
], | ||
@@ -27,0 +29,0 @@ "author": "Nikita 'donnikitos' Nitichevski <me@donnikitos.com> (https://donnikitos.com)", |
@@ -1,2 +0,2 @@ | ||
PromiseState | ||
usePromise | ||
=========== | ||
@@ -21,3 +21,5 @@ | ||
The setter function may take up to 2 parameters: 1st - Promise; 2nd - | ||
The setter function may take up to 2 parameters: | ||
* 1st - Promise | ||
* 2nd - Module Part to load (default is `default`) | ||
@@ -90,2 +92,2 @@ ```js | ||
[MIT](LICENSE). | ||
[MIT](LICENSE) Copyright (c) 2020 Nikita 'donnikitos' Nitichevski. |
5587
43
92