diff --git a/packages/cozy-mespapiers-lib/src/components/Hooks/useSessionstorage.jsx b/packages/cozy-mespapiers-lib/src/components/Hooks/useSessionstorage.jsx deleted file mode 100644 index acc3abf92f..0000000000 --- a/packages/cozy-mespapiers-lib/src/components/Hooks/useSessionstorage.jsx +++ /dev/null @@ -1,33 +0,0 @@ -// TODO Move to cozy-client -import { useState, useCallback } from 'react' - -import minilog from 'cozy-minilog' - -const log = minilog('useSessionstorage') - -export const useSessionstorage = (key, initialValue) => { - const [sessionValue, setSessionValueState] = useState(() => { - try { - const item = window.sessionStorage.getItem(key) - return item ? JSON.parse(item) : initialValue - } catch (error) { - log.error('Get item in sessionStorage failed', error) - return initialValue - } - }) - - const setSessionValue = useCallback( - value => { - try { - const valueToStore = - value instanceof Function ? value(sessionValue) : value - setSessionValueState(valueToStore) - window.sessionStorage.setItem(key, JSON.stringify(valueToStore)) - } catch (error) { - log.error('Set item in sessionStorage failed', error) - } - }, - [key, sessionValue] - ) - return [sessionValue, setSessionValue] -} diff --git a/packages/cozy-mespapiers-lib/src/components/Hooks/useSessionstorage.spec.jsx b/packages/cozy-mespapiers-lib/src/components/Hooks/useSessionstorage.spec.jsx deleted file mode 100644 index 3d701852f3..0000000000 --- a/packages/cozy-mespapiers-lib/src/components/Hooks/useSessionstorage.spec.jsx +++ /dev/null @@ -1,58 +0,0 @@ -import { - render, - cleanup, - getByTestId, - fireEvent, - act -} from '@testing-library/react' -import React from 'react' - -import { useSessionstorage } from './useSessionstorage' - -describe('useSessionstorage defined', () => { - it('should be defined', () => { - expect(useSessionstorage).toBeDefined() - }) -}) - -describe('useSessionstorage basic', () => { - let App - beforeEach(() => { - // eslint-disable-next-line react/display-name - App = function () { - const [value, set] = useSessionstorage('test-key', 'test value') - - return ( -
{value}
- -