File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -1005,8 +1005,6 @@ export function useRenderInfo(name = "Unknown") {
10051005 }
10061006}
10071007
1008- const cachedScriptStatuses = { } ;
1009-
10101008export function useScript ( src , options = { } ) {
10111009 const [ status , setStatus ] = React . useState ( ( ) => {
10121010 if ( ! src ) {
@@ -1016,12 +1014,14 @@ export function useScript(src, options = {}) {
10161014 return "loading" ;
10171015 } ) ;
10181016
1017+ const cachedScriptStatuses = React . useRef ( { } ) ;
1018+
10191019 React . useEffect ( ( ) => {
10201020 if ( ! src ) {
10211021 return ;
10221022 }
10231023
1024- const cachedScriptStatus = cachedScriptStatuses [ src ] ;
1024+ const cachedScriptStatus = cachedScriptStatuses . current [ src ] ;
10251025 if ( cachedScriptStatus === "ready" || cachedScriptStatus === "error" ) {
10261026 setStatus ( cachedScriptStatus ) ;
10271027 return ;
@@ -1055,7 +1055,7 @@ export function useScript(src, options = {}) {
10551055 const setStateFromEvent = ( event ) => {
10561056 const newStatus = event . type === "load" ? "ready" : "error" ;
10571057 setStatus ( newStatus ) ;
1058- cachedScriptStatuses [ src ] = newStatus ;
1058+ cachedScriptStatuses . current [ src ] = newStatus ;
10591059 } ;
10601060
10611061 script . addEventListener ( "load" , setStateFromEvent ) ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @uidotdev/usehooks" ,
3- "version" : " 0 .0.5 " ,
3+ "version" : " 2 .0.0 " ,
44 "description" : " A collection of Server Component safe React Hooks – from the ui.dev team" ,
55 "type" : " module" ,
66 "repository" : " uidotdev/usehooks" ,
You can’t perform that action at this time.
0 commit comments