Added useLocale hook.
This commit is contained in:
13
hooks/useLocale.js
Normal file
13
hooks/useLocale.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { updateApp } from 'redux/actions/app';
|
||||
|
||||
export default function useLocale() {
|
||||
const locale = useSelector(state => state.app.locale);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
function setLocale(value) {
|
||||
dispatch(updateApp({ locale: value }));
|
||||
}
|
||||
|
||||
return [locale, setLocale];
|
||||
}
|
||||
Reference in New Issue
Block a user