Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/eslint-plugin-react-hooks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import RulesOfHooks from './RulesOfHooks';
import ExhaustiveDeps from './ExhaustiveDeps';

const {name, version} = require('../package.json');

// All rules
export const rules = {
'rules-of-hooks': RulesOfHooks,
Expand All @@ -32,7 +30,7 @@ const legacyRecommendedConfig = {

// Base plugin object
const reactHooksPlugin = {
meta: {name, version},
meta: {name: 'eslint-plugin-react-hooks'},
rules,
};

Expand Down
10 changes: 9 additions & 1 deletion packages/react-client/src/ReactFlightClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2123,8 +2123,15 @@ function resolveErrorProd(response: Response): Error {

function resolveErrorDev(
response: Response,
errorInfo: {message: string, stack: ReactStackTrace, env: string, ...},
errorInfo: {
name: string,
message: string,
stack: ReactStackTrace,
env: string,
...
},
): Error {
const name: string = errorInfo.name;
const message: string = errorInfo.message;
const stack: ReactStackTrace = errorInfo.stack;
const env: string = errorInfo.env;
Expand Down Expand Up @@ -2156,6 +2163,7 @@ function resolveErrorDev(
error = callStack();
}

(error: any).name = name;
(error: any).environmentName = env;
return error;
}
Expand Down
14 changes: 12 additions & 2 deletions packages/react-client/src/__tests__/ReactFlight-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,17 @@ describe('ReactFlight', () => {
});

it('can transport Error objects as values', async () => {
class CustomError extends Error {
constructor(message) {
super(message);
this.name = 'Custom';
}
}

function ComponentClient({prop}) {
return `
is error: ${prop instanceof Error}
name: ${prop.name}
message: ${prop.message}
stack: ${normalizeCodeLocInfo(prop.stack).split('\n').slice(0, 2).join('\n')}
environmentName: ${prop.environmentName}
Expand All @@ -705,7 +713,7 @@ describe('ReactFlight', () => {
const Component = clientReference(ComponentClient);

function ServerComponent() {
const error = new Error('hello');
const error = new CustomError('hello');
return <Component prop={error} />;
}

Expand All @@ -718,14 +726,16 @@ describe('ReactFlight', () => {
if (__DEV__) {
expect(ReactNoop).toMatchRenderedOutput(`
is error: true
name: Custom
message: hello
stack: Error: hello
stack: Custom: hello
in ServerComponent (at **)
environmentName: Server
`);
} else {
expect(ReactNoop).toMatchRenderedOutput(`
is error: true
name: Error
message: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
stack: Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.
environmentName: undefined
Expand Down
Loading
Loading