wappsto-blanket
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -97,3 +97,3 @@ import { useState, useEffect, useCallback, useRef, useMemo } from 'react'; | ||
const [ customRequest, setCustomRequest ] = useState(); | ||
const [ customRequest, setCustomRequest ] = useState({ status: 'pending' }); | ||
const { request, setRequestId } = useRequest(); | ||
@@ -160,4 +160,5 @@ const name = props.name || (propsData.url + JSON.stringify(propsData.query)); | ||
if((!fetched && (!request || request.status !== 'pending')) || (fetched && request && request.status === 'error')){ | ||
dispatch(setItem(fetchedItemName, true)); | ||
refresh(props.reset); | ||
} else { | ||
setCustomRequest({ status: 'success' }); | ||
} | ||
@@ -210,2 +211,3 @@ // eslint-disable-next-line react-hooks/exhaustive-deps | ||
setCustomRequest(request); | ||
dispatch(setItem(fetchedItemName, true)); | ||
} | ||
@@ -212,0 +214,0 @@ } |
import { useMemo, useState, useCallback } from 'react'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { makeRequestSelector } from 'wappsto-redux/selectors/request'; | ||
import { makeRequest } from 'wappsto-redux/actions/request'; | ||
import { makeRequest, removeRequest } from 'wappsto-redux/actions/request'; | ||
const useRequestSelector = () => { | ||
const dispatch = useDispatch(); | ||
const [ requestId, setRequestId ] = useState(); | ||
const getRequest = useMemo(makeRequestSelector, []); | ||
const request = useSelector(state => getRequest(state, requestId)); | ||
const dispatch = useDispatch(); | ||
const send = useCallback((...args) => { | ||
const newId = dispatch(makeRequest(...args)); | ||
setRequestId(newId); | ||
return newId; | ||
}, [dispatch]); | ||
return { request, requestId, setRequestId, send }; | ||
const removeRequest = useCallback(() => { | ||
dispatch(removeRequest(requestId)); | ||
}, [requestId]); | ||
return { request, requestId, setRequestId, send, removeRequest }; | ||
} | ||
export default useRequestSelector; |
{ | ||
"name": "wappsto-blanket", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -167,1 +167,5 @@ import { getServiceVersion } from 'wappsto-redux/util/helpers'; | ||
} | ||
export function getDottedText(text, num = 4, separator = ' ... ') => { | ||
return text.slice(0,num) + separator + text.slice(-num); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27836
832