File tree Expand file tree Collapse file tree 1 file changed +9
-15
lines changed
Expand file tree Collapse file tree 1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -42,34 +42,28 @@ const defaultSWRParams = {
4242const swrMachine : FSMMachineConfig = {
4343 initial : "init" ,
4444 on : {
45- revalidate : {
46- target : "revalidating" ,
47- action : ( ctx , event ) => {
45+ revalidate : "revalidating" ,
46+ } ,
47+ states : {
48+ init : { } ,
49+ revalidating : {
50+ entry : ( ctx , event ) => {
4851 if ( cache . has ( event . data . key ) ) {
49- return { ...ctx , isLoading : false , data : cache . get ( event . data . key ) } ;
52+ ctx = { ...ctx , isLoading : false , data : cache . get ( event . data . key ) } ;
5053 } else if ( event . data . options . initialData ) {
5154 const data = event . data . options . initialData ( ) ;
5255 if ( data ) {
53- return { ...ctx , isLoading : false , data } ;
56+ ctx = { ...ctx , isLoading : false , data } ;
5457 }
5558 }
56- } ,
57- } ,
58- } ,
59- states : {
60- init : { } ,
61- revalidating : {
62- entry : ( ctx ) => {
6359 increaseFetching ( ) ;
6460 return { ...ctx , isFetching : true } ;
6561 } ,
6662 on : {
6763 revalidate : null ,
6864 } ,
6965 invoke : {
70- src : ( _ , event ) => {
71- return event . data . fn ( ) ;
72- } ,
66+ src : ( _ , event ) => event . data . fn ( ) ,
7367 onDone : {
7468 target : "success" ,
7569 action : ( ctx , event ) => {
You can’t perform that action at this time.
0 commit comments