Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
function useTrie(
initialWords: Word[],
isCaseInsensitive = true,
getText: TextSelector = obj => obj
): ITrie {
const trie = new Trie(initialWords, isCaseInsensitive, getText);
const [state, dispatch] = React.useReducer(reducer, { trie, word: '' });
// add/remove removed for brivity
return { ...state.trie, add, remove };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment