You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rather than using your selector directly on your page, wrap it in a component and then put a Suspense around it.
importHeadfrom'next/head'importstylesfrom'../styles/Home.module.css'import{Suspense}from'react';import{useRecoilValue}from"recoil";import{charCountState}from"../src/testState";constCount=>{const count =useRecoilValue(charCountState);return(<>{count}</>);}exportdefaultfunctionHome(){return(<><Head><title>Create Next App</title><metaname="description"content="Generated by create next app"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="icon"href="/favicon.ico"/></Head><mainclassName={styles.main}><Suspensefallback='Loading...'><Count/></Suspense></main></>)}
Use useRecoilValueLoadable intead of useRecoilValue.
importHeadfrom'next/head'importstylesfrom'../styles/Home.module.css'import{useRecoilValueLoadable}from"recoil";import{charCountState}from"../src/testState";exportdefaultfunctionHome(){constcount=useRecoilValueLoadable(charCountState);return(<><Head><title>Create Next App</title><metaname="description"content="Generated by create next app"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="icon"href="/favicon.ico"/></Head><mainclassName={styles.main}>{count.state=='hasValue' ? count.getValue() : null}</main></>);}
Doing async on selector's get causes build to time out.
Example project: https://github.com/minakawa-daiki/recoil-build-test
If you remove the async in the following line, the build will pass without incident.
https://github.com/minakawa-daiki/recoil-build-test/blob/main/src/testState.ts#L10
I believe this is a bug in Recoil.
The text was updated successfully, but these errors were encountered: