@samitouri / QOS-React / commits / d42ed60026

Fix Suspense fixture (#13932)

Dan Abramov committed Oct 23, 2018 at 18:03 UTC d42ed600266302034085551a465ee479e4ade9d1
4 files changed +6 -15
fixtures/unstable-async/suspense/src/cache.js deleted
-7
@@ -1,7 +0,0 @@
1 -import {createCache} from 'react-cache';
2 -
3 -export let cache;
4 -function initCache() {
5 - cache = createCache(initCache);
6 -}
7 -initCache();
fixtures/unstable-async/suspense/src/components/ContributorListPage.js
+1 -2
@@ -1,6 +1,5 @@
1 import React, {Fragment} from 'react';
2 import {unstable_createResource} from 'react-cache';
3 -import {cache} from '../cache';
3 import Spinner from './Spinner';
4 import {fetchCoreContributorListJSON} from '../api';
5
@@ -19,7 +18,7 @@ const ContributorListPage = ({loadingId, onUserClick}) => (
18 padding: 0,
19 margin: 0,
20 }}>
22 - {ContributorListResource.read(cache).map(user => (
21 + {ContributorListResource.read().map(user => (
22 <ContributorListItem
23 key={user.id}
24 onClick={() => onUserClick(user.id)}
fixtures/unstable-async/suspense/src/components/UserPage.js
+3 -4
@@ -1,7 +1,6 @@
1 import React, {Suspense} from 'react';
2 import {unstable_createResource} from 'react-cache';
3 import Spinner from './Spinner';
4 -import {cache} from '../cache';
4 import {fetchUserProfileJSON, fetchUserRepositoriesListJSON} from '../api';
5
6 export default function UserPage({id}) {
@@ -24,7 +23,7 @@ export default function UserPage({id}) {
23 const UserDetailsResource = unstable_createResource(fetchUserProfileJSON);
24
25 function UserDetails({id}) {
27 - const user = UserDetailsResource.read(cache, id);
26 + const user = UserDetailsResource.read(id);
27 return (
28 <div
29 style={{
@@ -113,7 +112,7 @@ const ImageResource = unstable_createResource(
112 );
113
114 function Img({src, alt, ...rest}) {
116 - return <img src={ImageResource.read(cache, src)} alt={alt} {...rest} />;
115 + return <img src={ImageResource.read(src)} alt={alt} {...rest} />;
116 }
117
118 function UserPicture({source}) {
@@ -137,7 +136,7 @@ const UserRepositoriesResource = unstable_createResource(
136 );
137
138 function Repositories({id}) {
140 - const repos = UserRepositoriesResource.read(cache, id);
139 + const repos = UserRepositoriesResource.read(id);
140 return (
141 <ul
142 style={{
fixtures/unstable-async/suspense/src/index.js
+2 -2
@@ -1,7 +1,6 @@
1 import React, {Fragment, PureComponent} from 'react';
2 import {unstable_createRoot, render} from 'react-dom';
3 import {unstable_trace as trace} from 'scheduler/tracing';
4 -import {cache} from './cache';
4 import {
5 setFakeRequestTime,
6 setPaused,
@@ -66,7 +65,8 @@ class Debugger extends PureComponent {
65
66 handleReset = () => {
67 trace('Clear cache', performance.now(), () => {
69 - cache.invalidate();
68 + // TODO: this is not implemented.
69 + // cache.invalidate();
70 this.setState(state => ({
71 requests: {},
72 }));