@brightleaf/react-hooks
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -31,3 +31,3 @@ "use strict"; | ||
await waitForNextUpdate(); | ||
expect(result.current.data).toBe('12345'); | ||
expect(result.current.data).toBe(12345); | ||
}); | ||
@@ -34,0 +34,0 @@ test('should make handle error', async () => { |
@@ -28,3 +28,3 @@ "use strict"; | ||
await waitForNextUpdate(); | ||
expect(result.current.data).toBe('12345'); | ||
expect(result.current.data).toBe(12345); | ||
}); | ||
@@ -31,0 +31,0 @@ test('should make handle error', async () => { |
@@ -9,6 +9,11 @@ "use strict"; | ||
const getData = obj => { | ||
if (obj && obj.data && obj.data.data) return obj.data.data; | ||
if (obj && obj.data) return obj.data; | ||
if (obj.data === null) return null; | ||
return obj; | ||
const data = obj && typeof obj.data === 'string' ? JSON.parse(obj.data) : obj; | ||
if (data && data.data) { | ||
return data.data; | ||
} else if (Array.isArray(data)) { | ||
return data; | ||
} | ||
return data; | ||
}; | ||
@@ -44,3 +49,3 @@ | ||
return { ...state, | ||
data: action.payload.data, | ||
data: getData(action.payload), | ||
error: null, | ||
@@ -53,3 +58,3 @@ loading: false, | ||
return { ...state, | ||
data: getData(action.payload), | ||
data: getData(action.payload.data), | ||
error: true, | ||
@@ -56,0 +61,0 @@ errorDetails: getError(action.payload), |
@@ -112,6 +112,4 @@ "use strict"; | ||
const { | ||
data, | ||
error, | ||
loading, | ||
makeRequest | ||
makeRequest, | ||
...props | ||
} = (0, _useRequest.useRequest)(url, { | ||
@@ -139,6 +137,4 @@ data: null, | ||
return { | ||
data, | ||
error, | ||
loading, | ||
makeQuery | ||
makeQuery, | ||
...props | ||
}; | ||
@@ -145,0 +141,0 @@ }; |
{ | ||
"name": "@brightleaf/react-hooks", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Useful react hooks", | ||
@@ -43,4 +43,3 @@ "files": [ | ||
"dependencies": { | ||
"@hapi/nes": "^11.2.2", | ||
"graphql-request": "^1.8.2" | ||
"@hapi/nes": "^11.2.2" | ||
}, | ||
@@ -65,2 +64,3 @@ "devDependencies": { | ||
"eslint-plugin-react-hooks": "^2.0.1", | ||
"graphql-request": "^1.8.2", | ||
"hash-source": "^1.0.4", | ||
@@ -90,3 +90,4 @@ "html-loader": "^0.5.5", | ||
"peerDependencies": { | ||
"react": ">= 16.8.6" | ||
"react": ">= 16.8.6", | ||
"graphql-request": "^1.8.2" | ||
}, | ||
@@ -93,0 +94,0 @@ "jest": { |
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
118823
40
3592
- Removedgraphql-request@^1.8.2