Moved code into src folder. Added build for component library.
This commit is contained in:
20
src/components/hooks/useTimezone.js
Normal file
20
src/components/hooks/useTimezone.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { getTimezone } from 'lib/date';
|
||||
import { getItem, setItem } from 'next-basics';
|
||||
import { TIMEZONE_CONFIG } from 'lib/constants';
|
||||
|
||||
export function useTimezone() {
|
||||
const [timezone, setTimezone] = useState(getItem(TIMEZONE_CONFIG) || getTimezone());
|
||||
|
||||
const saveTimezone = useCallback(
|
||||
value => {
|
||||
setItem(TIMEZONE_CONFIG, value);
|
||||
setTimezone(value);
|
||||
},
|
||||
[setTimezone],
|
||||
);
|
||||
|
||||
return [timezone, saveTimezone];
|
||||
}
|
||||
|
||||
export default useTimezone;
|
||||
Reference in New Issue
Block a user