<commit_before>import { shallowEqual, useSelector } from 'react-redux'

import { Tag, RootState, Option } from 'core/types'
import { createSelector } from 'reselect'
import { InventoryState } from 'core/features/inventory'
import React from 'react'

const makeInventorySelector = () =>
    createSelector(
        (state: RootState) => state.inventory.present,
        (state: RootState, tag: Tag) => tag,
        (inv: InventoryState, tag: Tag) => {
            if (tag in inv) {
                return inv[tag]
            }
            return undefined
        },
        {
            memoizeOptions: {
                equalityCheck: (a, b) => a === b,
                resultEqualityCheck: shallowEqual
            }
        }
    )
const useInventoryItem = (tag: Tag): Option => {
    const selectInventoryItem = React.useMemo(makeInventorySelector, [])
    return useSelector((state: RootState) => selectInventoryItem(state, tag))
}
/**<commit_msg>More explicitly handle memoizing of use-inventory<commit_after>import { shallowEqual, useSelector } from 'react-redux'

import { Tag, RootState, Option } from 'core/types'
import { createSelector } from 'reselect'
import { InventoryState } from 'core/features/inventory'
import React from 'react'

const makeInventorySelector = () =>
    createSelector(
        (state: RootState) => state.inventory.present,
        (state: RootState, tag: Tag) => tag,
        (inv: InventoryState, tag: Tag) => {
            if (tag in inv) {
                return inv[tag]
            }
            return undefined
        },
        {
            memoizeOptions: {
                resultEqualityCheck: shallowEqual
            }
        }
    )
const useInventoryItem = (tag: Tag): Option => {
    const selectInventoryItem = React.useMemo(makeInventorySelector, [])
    return useSelector((state: RootState) => selectInventoryItem(state, tag))
}

/**
{'fraction_non_alphanumeric': 0.11345646437994723, 'fraction_numerical': 0.0, 'mean_word_length': 2.4661791590493602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3191295', 'n_tokens_mistral': 531, 'n_tokens_neox': 524, 'n_words': 134}