scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
26 lines (20 loc) • 588 B
text/typescript
import { useEffect } from 'react';
import { localStorage, selectBoard, selectRack, selectSettings, useTypedSelector } from '@/state';
export const useLocalStorage = () => {
const board = useTypedSelector(selectBoard);
const rack = useTypedSelector(selectRack);
const settings = useTypedSelector(selectSettings);
useEffect(() => {
if (board) {
localStorage.setBoard(board);
}
}, [board]);
useEffect(() => {
if (rack) {
localStorage.setRack(rack);
}
}, [rack]);
useEffect(() => {
localStorage.setSettings(settings);
}, [settings]);
};