Was looking at examples on reselect's createSelector at https://react-redux.js.org/next/api/hooks#using-memoizing-selectors.
What is the _ in (_,isDone) => isDone?
Is it lodash? How did it get injected? Was it injected by the library?
import React, { useMemo } from 'react' import { useSelector } from 'react-redux' import { createSelector } from 'reselect' const makeNumOfTodosWithIsDoneSelector = () => createSelector( state => state.todos, (_, isDone) => isDone, (todos, isDone) => todos.filter(todo => todo.isDone === isDone).length ) export const TodoCounterForIsDoneValue = ({ isDone }) => { const selectNumOfTodosWithIsDone = useMemo( makeNumOfTodosWithIsDoneSelector, [] ) const numOfTodosWithIsDoneValue = useSelector(state => selectNumOfTodosWithIsDone(state, isDone) ) return <div>{numOfTodosWithIsDoneValue}</div> } export const App = () => { return ( <> <span>Number of done todos:</span> <TodoCounterForIsDoneValue isDone={true} /> <span>Number of unfinished todos:</span> <TodoCounterForIsDoneValue isDone={false} /> </> ) }
_will prevent the behavior. Take a look at this answerreselectworks then :).