@@ -493,7 +493,6 @@ export interface CreateAtomStoreOptions<
493493 delay ?: UseAtomOptions [ 'delay' ] ;
494494 effect ?: React . FC ;
495495 extend ?: ( atomsWithoutExtend : StoreAtomsWithoutExtend < T > ) => E ;
496- infiniteRenderDetectionLimit ?: number ;
497496 suppressWarnings ?: boolean ;
498497}
499498
@@ -520,7 +519,6 @@ export const createAtomStore = <
520519 delay : delayRoot ,
521520 effect,
522521 extend,
523- infiniteRenderDetectionLimit = 100_000 ,
524522 suppressWarnings,
525523 } : CreateAtomStoreOptions < T , E , N >
526524) : AtomStoreApi < T , E , N > => {
@@ -584,8 +582,6 @@ export const createAtomStore = <
584582 return store ?? contextStore ;
585583 } ;
586584
587- let renderCount = 0 ;
588-
589585 const useAtomValueWithStore : UseAtomValueFn = (
590586 atomConfig ,
591587 store ,
@@ -594,25 +590,6 @@ export const createAtomStore = <
594590 equalityFnOrDeps ,
595591 deps
596592 ) => {
597- // If selector/equalityFn are not memoized, infinite loop will occur.
598- if ( process . env . NODE_ENV !== 'production' && infiniteRenderDetectionLimit ) {
599- renderCount += 1 ;
600- if ( renderCount > infiniteRenderDetectionLimit ) {
601- throw new Error (
602- `
603- use<Key>Value/useValue/use<StoreName>Value has rendered ${ infiniteRenderDetectionLimit } times in the same render.
604- It is very likely to have fallen into an infinite loop.
605- That is because you do not memoize the selector/equalityFn function param.
606- Please wrap them with useCallback or configure the deps array correctly.`
607- ) ;
608- }
609- // We need to use setTimeout instead of useEffect here, because when infinite loop happens,
610- // the effect (fired in the next micro task) will execute before the rerender.
611- setTimeout ( ( ) => {
612- renderCount = 0 ;
613- } ) ;
614- }
615-
616593 const options = convertScopeShorthand ( optionsOrScope ) ;
617594 selector ??= identity ;
618595 const equalityFn =
0 commit comments