@@ -421,7 +421,6 @@ export interface CreateAtomStoreOptions<
421421 delay ?: UseAtomOptions [ 'delay' ] ;
422422 effect ?: React . FC ;
423423 extend ?: ( atomsWithoutExtend : StoreAtomsWithoutExtend < T > ) => E ;
424- infiniteRenderDetectionLimit ?: number ;
425424 suppressWarnings ?: boolean ;
426425}
427426
@@ -448,7 +447,6 @@ export const createAtomStore = <
448447 delay : delayRoot ,
449448 effect,
450449 extend,
451- infiniteRenderDetectionLimit = 100_000 ,
452450 suppressWarnings,
453451 } : CreateAtomStoreOptions < T , E , N >
454452) : AtomStoreApi < T , E , N > => {
@@ -510,8 +508,6 @@ export const createAtomStore = <
510508 return store ?? contextStore ;
511509 } ;
512510
513- let renderCount = 0 ;
514-
515511 const useAtomValueWithStore : UseAtomValueFn = (
516512 atomConfig ,
517513 store ,
@@ -520,25 +516,6 @@ export const createAtomStore = <
520516 equalityFnOrDeps ,
521517 deps
522518 ) => {
523- // If selector/equalityFn are not memoized, infinite loop will occur.
524- if ( process . env . NODE_ENV !== 'production' && infiniteRenderDetectionLimit ) {
525- renderCount += 1 ;
526- if ( renderCount > infiniteRenderDetectionLimit ) {
527- throw new Error (
528- `
529- use<Key>Value/useValue/use<StoreName>Value has rendered ${ infiniteRenderDetectionLimit } times in the same render.
530- It is very likely to have fallen into an infinite loop.
531- That is because you do not memoize the selector/equalityFn function param.
532- Please wrap them with useCallback or configure the deps array correctly.`
533- ) ;
534- }
535- // We need to use setTimeout instead of useEffect here, because when infinite loop happens,
536- // the effect (fired in the next micro task) will execute before the rerender.
537- setTimeout ( ( ) => {
538- renderCount = 0 ;
539- } ) ;
540- }
541-
542519 const options = convertScopeShorthand ( optionsOrScope ) ;
543520 const equalityFn =
544521 typeof equalityFnOrDeps === 'function' ? equalityFnOrDeps : undefined ;
0 commit comments