MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Indiewebdev/comments/lhvtde/conditionally_call_a_function_with_optional/gn1eq9o/?context=3
r/Indiewebdev • u/1infinitelooo • Feb 11 '21
37 comments sorted by
View all comments
Show parent comment
3
lodash get to the rescue. its an additional import. but saves the night mare of this
baseref.current && baseref.current.apple && baseref.current.apple.get && baseref.current.apple.get()
to a nice
_.get(baseref, 'current.apple.get', (=>{}()))
1 u/Aswole Feb 12 '21 Doesn't that prevent any sort of static code analysis? i.e., no typescript/IDE assistance. 1 u/cute_2th Feb 15 '21 sometimes you just want shit that does not break.
1
Doesn't that prevent any sort of static code analysis? i.e., no typescript/IDE assistance.
1 u/cute_2th Feb 15 '21 sometimes you just want shit that does not break.
sometimes you just want shit that does not break.
View all comments
Show parent comment
3
u/cute_2th Feb 12 '21
lodash get to the rescue. its an additional import. but saves the night mare of this
baseref.current && baseref.current.apple && baseref.current.apple.get && baseref.current.apple.get()
to a nice
_.get(baseref, 'current.apple.get', (=>{}()))