As a newcomer to React, please excuse any novice questions I may have. I am currently utilizing npx create-react-app
to develop a React app, but I'm unsure of the inner workings:
Q1-If I were to throw an error in a component like so:
import React, { Component } from "react";
...
render() {
throw new Error("something went wrong");
}
I did not import the Error name feature from any modules, so where does Error
originate? How is it possible for me to utilize it directly without importing related modules such as:
import Error from "XXX";
Q2-After creating a react app, there exists a test file named app.test.js, within which there is a function called it()
as follows:
it('renders without crashing', () => {
...
});
Therefore, where does it
come from? Also, why is there no need for me to import any module to incorporate it?