Credit: Re-export from react-use
React side-effect hook that returns an error dispatcher.
import { useError } from "@lynx-js/react-use"; const Demo = () => { const dispatchError = useError(); const tapHandler = () => { "background only"; dispatchError(new Error("Some error!")); }; return <view bindtap={tapHandler}>Click me to throw</view>; }; // In parent app const App = () => ( <ErrorBoundary> <Demo /> </ErrorBoundary> );
declare const useError: () => (err: Error) => void;