Skip to content

Commit

Permalink
comment_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeux committed May 14, 2020
1 parent 589bedf commit cc90b0b
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 62 deletions.
16 changes: 8 additions & 8 deletions src/components/Recoil_RecoilRoot.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ function Batcher(props: {setNotifyBatcherOfChange: (() => void) => void}) {
return null;
}

if (__DEV__) {
if (!window.$recoilDebugStates) {
window.$recoilDebugStates = [];
}
}
// if (__DEV__) {
// if (!window.$recoilDebugStates) {
// window.$recoilDebugStates = [];
// }
// }

function makeEmptyTreeState(): TreeState {
return {
Expand Down Expand Up @@ -211,9 +211,9 @@ function RecoilRoot({initializeState, children}: Props): ReactElement {
return;
}
// Save changes to nextTree and schedule a React update:
if (__DEV__) {
window.$recoilDebugStates.push(replaced); // TODO this shouldn't happen here because it's not batched
}
// if (__DEV__) {
// window.$recoilDebugStates.push(replaced); // TODO this shouldn't happen here because it's not batched
// }
storeState.nextTree = replaced;
nullthrows(notifyBatcherOfChange.current)();
};
Expand Down
14 changes: 7 additions & 7 deletions src/core/Recoil_Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ function registerNode<T>(node: Node<T>): RecoilValue<T> {
const message = `Duplicate atom key "${node.key}". This is a FATAL ERROR in
production. But it is safe to ignore this warning if it occured because of
hot module replacement.`;
if (__DEV__) {
const isAcceptingUpdate = require('../util/Recoil__debug').isAcceptingUpdate;
if (typeof isAcceptingUpdate !== 'function' || !isAcceptingUpdate()) {
expectationViolation(message, 'recoil');
}
} else {
// if (__DEV__) {
// const isAcceptingUpdate = require('../util/Recoil__debug').isAcceptingUpdate;
// if (typeof isAcceptingUpdate !== 'function' || !isAcceptingUpdate()) {
// expectationViolation(message, 'recoil');
// }
// } else {
recoverableViolation(message, 'recoil');
}
// }
}
nodes.set(node.key, node);

Expand Down
6 changes: 3 additions & 3 deletions src/recoil_values/Recoil_selector_NEW.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,9 @@ function selector<T>(
};
}

if (__DEV__) {
detectCircularDependencies(newState, [key]);
}
// if (__DEV__) {
// detectCircularDependencies(newState, [key]);
// }

return newState;
}
Expand Down
6 changes: 3 additions & 3 deletions src/recoil_values/Recoil_selector_OLD.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ function selector<T>(
};
}

if (__DEV__) {
detectCircularDependencies(newState, [key]);
}
// if (__DEV__) {
// detectCircularDependencies(newState, [key]);
// }
return [newState, loadable, newDepValues];
}

Expand Down
38 changes: 19 additions & 19 deletions src/util/Recoil_Tracing.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ function trace<TResult>(
node: string | RecoilValue<mixed>,
fn: () => TResult,
): TResult {
if (__DEV__) {
if (
SchedulerTracing.unstable_trace !== undefined &&
window.performance !== undefined
) {
return SchedulerTracing.unstable_trace(
`Recoil: ${message} for node: ${
typeof node === 'string' ? node : node.key
}`,
window.performance.now(),
fn,
);
}
}
// if (__DEV__) {
// if (
// SchedulerTracing.unstable_trace !== undefined &&
// window.performance !== undefined
// ) {
// return SchedulerTracing.unstable_trace(
// `Recoil: ${message} for node: ${
// typeof node === 'string' ? node : node.key
// }`,
// window.performance.now(),
// fn,
// );
// }
// }
return fn();
}

function wrap<TFunction>(fn: TFunction): TFunction {
if (__DEV__) {
if (SchedulerTracing.unstable_wrap !== undefined) {
return SchedulerTracing.unstable_wrap(fn);
}
}
// if (__DEV__) {
// if (SchedulerTracing.unstable_wrap !== undefined) {
// return SchedulerTracing.unstable_wrap(fn);
// }
// }
return fn;
}

Expand Down
12 changes: 6 additions & 6 deletions src/util/Recoil_expectationViolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

const sprintf = require('./Recoil_sprintf');
function expectationViolation(format: string, ...args: $ReadOnlyArray<mixed>) {
if (__DEV__) {
const message = sprintf.call(null, format, ...args);
const error = new Error(message);
error.name = 'Expectation Violation';
console.error(error);
}
// if (__DEV__) {
// const message = sprintf.call(null, format, ...args);
// const error = new Error(message);
// error.name = 'Expectation Violation';
// console.error(error);
// }
}

module.exports = expectationViolation;
6 changes: 3 additions & 3 deletions src/util/Recoil_recoverableViolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function recoverableViolation(
projectName: 'recoil',
{error}: {|error?: Error|},
): null {
if (__DEV__) {
console.error(message, error);
}
// if (__DEV__) {
// console.error(message, error);
// }
return null;
}

Expand Down
26 changes: 13 additions & 13 deletions src/util/Recoil_stableStringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,22 @@ function stringify(x: mixed, opt: Options, key?: string): string {
// * We could support BigInt, but Flow doesn't seem to like it.
// See Recoil_stableStringify-test.js for examples
function stableStringify(x: mixed, opt?: Options): string {
const startTime = window.performance ? window.performance.now() : 0;
// const startTime = window.performance ? window.performance.now() : 0;
const str = stringify(x, opt ?? {allowFunctions: undefined});
const endTime = window.performance ? window.performance.now() : 0;
if (__DEV__) {
if (endTime - startTime > TIME_WARNING_THRESHOLD_MS) {
/* eslint-disable fb-www/no-console */
console.groupCollapsed(
`Recoil: Spent ${endTime - startTime}ms computing a cache key`,
);
console.warn(x, str);
console.groupEnd();
/* eslint-enable fb-www/no-console */
}
}
// const endTime = window.performance ? window.performance.now() : 0;
// if (__DEV__) {
// if (endTime - startTime > TIME_WARNING_THRESHOLD_MS) {
// /* eslint-disable fb-www/no-console */
// console.groupCollapsed(
// `Recoil: Spent ${endTime - startTime}ms computing a cache key`,
// );
// console.warn(x, str);
// console.groupEnd();
// /* eslint-enable fb-www/no-console */
// }
// }
return str;
}

Expand Down

0 comments on commit cc90b0b

Please sign in to comment.