1.0.1 - Added useTuitioClient default options
parent
627d1af5ad
commit
67035fbc7e
|
@ -34,4 +34,5 @@ All tests in the package can be executed by running: `npm test`.
|
|||
|
||||
## Changelog
|
||||
|
||||
1.0.0 - Package initialization
|
||||
1.0.0 - Package initialization
|
||||
1.0.1 - Added useTuitioClient default options
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@flare/tuitio-client-react",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@flare/tuitio-client-react",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@flare/tuitio-client": "^1.0.4"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@flare/tuitio-client-react",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Tuitio client react is an npm package written in typescript that facilitates the integration of a react application with Tuitio.",
|
||||
"main": "./dist/cjs/index.js",
|
||||
"module": "./dist/esm/index.js",
|
||||
|
|
|
@ -4,12 +4,18 @@ import { TuitioClient, invalidate } from "@flare/tuitio-client";
|
|||
import type { TuitioAuthenticationResult } from "@flare/tuitio-client";
|
||||
|
||||
export type TuitioClientHookOptions = {
|
||||
onLoginSuccess: (result: TuitioAuthenticationResult, userName: string) => void;
|
||||
onLoginFailed: (result: TuitioAuthenticationResult, userName: string) => void;
|
||||
onLoginError: (error: any) => void;
|
||||
onLoginSuccess?: (result: TuitioAuthenticationResult, userName: string) => void;
|
||||
onLoginFailed?: (result: TuitioAuthenticationResult, userName: string) => void;
|
||||
onLoginError?: (error: any) => void;
|
||||
};
|
||||
|
||||
const useTuitioClient = (options: TuitioClientHookOptions) => {
|
||||
const defaultOptions: TuitioClientHookOptions = {
|
||||
onLoginSuccess: undefined,
|
||||
onLoginFailed: undefined,
|
||||
onLoginError: undefined
|
||||
};
|
||||
|
||||
const useTuitioClient = (options: TuitioClientHookOptions = defaultOptions) => {
|
||||
const state = useContext(TuitioContext);
|
||||
const dispatchActions = useContext(TuitioDispatchContext);
|
||||
|
||||
|
|
|
@ -102,13 +102,7 @@ describe("useTuitioClient", () => {
|
|||
});
|
||||
|
||||
it("should call invalidate when logout is called", () => {
|
||||
const { result } = renderHook(() =>
|
||||
useTuitioClient({
|
||||
onLoginSuccess: jest.fn(),
|
||||
onLoginFailed: jest.fn(),
|
||||
onLoginError: jest.fn()
|
||||
})
|
||||
);
|
||||
const { result } = renderHook(() => useTuitioClient());
|
||||
|
||||
act(() => {
|
||||
result.current.logout();
|
||||
|
|
Loading…
Reference in New Issue