This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
// Call the provided function with the provided value as the only argument, | |
// if the call throws an exception, return the original value, otherwise | |
// return the result of applying fn to val | |
function attempt(fn, val) { | |
try { | |
return fn(val) | |
} catch (e) { | |
return val |