Webpack imported module is undefined
Answered
Mugger Crocodile posted this in #help-forum
Mugger CrocodileOP
Hi there! I'm getting a nasty error for one component which was working flawlessly prior to v14 upgrade. It's getting frustrating.
Among other imports, none of which is also from lodash, I have
Then in my code...
Then, the error:
I'm quite sure lodash is installed, as at the console, upon console.logging the function just before that line, I see
Any help or troubleshooting pointers will be greatly appreciated
Thanks
Among other imports, none of which is also from lodash, I have
import { find } from 'lodash'Then in my code...
const EventCard = ({ evento }: EventCardProps) => {
console.log('Find:');
console.log(find);
const organizacion = find(entidades, e => e.id == evento.por)!.txt
const findEspecialidad = (esp: string) => find(especialidades, e => e.id == esp)!.txt
return <>{...organizacion and findEspecialidad used somehow...}</>
}Then, the error:
Unhandled Runtime Error
TypeError: lodash_find__WEBPACK_IMPORTED_MODULE_2___default()(...) is undefinedsrc/components/eventList/eventCard.tsx (37:49) @ especialidades 35 | console.log(find);
36 | const organizacion = find(entidades, e => e.id == evento.por)!.txt
> 37 | const findEspecialidad = (esp: string) => find(especialidades, e => e.id == esp)!.txt
| ^I'm quite sure lodash is installed, as at the console, upon console.logging the function just before that line, I see
Find:
function createFind(collection, predicate, fromIndex)Any help or troubleshooting pointers will be greatly appreciated
Thanks
Answered by Mugger Crocodile
D4mmit it was just looking like it meant the function itself but it meant the result of the function invocation. Correctly handling the case in which no especialidad is found fixed the issue.
1 Reply
Mugger CrocodileOP
D4mmit it was just looking like it meant the function itself but it meant the result of the function invocation. Correctly handling the case in which no especialidad is found fixed the issue.
Answer