I want to get the component from another file to the try-catch block. So for the example i created the component in one file
const Example = () => {
return (
<div>
<h2>this is a test</h2>
</div>
);
}
export default Example.
And in the App.js file i have a try-catch block but when i import new component to the catch it is not shown. But if a call the same component in the return statement it is shown. so for example
import Example from "./filename"
function App() {
function clickFail() {
try {
console.log(window.device.version)
} catch (e) {
< Example />
}
}
}
return (
<div className="App">
<button onClick={clickFail}>failed</button>
//if a call it from here it is shown.
// < Example />
</div>
);
export default App;