From d42ed600266302034085551a465ee479e4ade9d1 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 23 Oct 2018 18:03:22 -0400 Subject: [PATCH] Fix Suspense fixture (#13932) --- fixtures/unstable-async/suspense/src/cache.js | 7 ------- .../suspense/src/components/ContributorListPage.js | 3 +-- .../unstable-async/suspense/src/components/UserPage.js | 7 +++---- fixtures/unstable-async/suspense/src/index.js | 4 ++-- 4 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 fixtures/unstable-async/suspense/src/cache.js diff --git a/fixtures/unstable-async/suspense/src/cache.js b/fixtures/unstable-async/suspense/src/cache.js deleted file mode 100644 index 467e2df15f182..0000000000000 --- a/fixtures/unstable-async/suspense/src/cache.js +++ /dev/null @@ -1,7 +0,0 @@ -import {createCache} from 'react-cache'; - -export let cache; -function initCache() { - cache = createCache(initCache); -} -initCache(); diff --git a/fixtures/unstable-async/suspense/src/components/ContributorListPage.js b/fixtures/unstable-async/suspense/src/components/ContributorListPage.js index 351703ffe9e7e..f352d879ad423 100644 --- a/fixtures/unstable-async/suspense/src/components/ContributorListPage.js +++ b/fixtures/unstable-async/suspense/src/components/ContributorListPage.js @@ -1,6 +1,5 @@ import React, {Fragment} from 'react'; import {unstable_createResource} from 'react-cache'; -import {cache} from '../cache'; import Spinner from './Spinner'; import {fetchCoreContributorListJSON} from '../api'; @@ -19,7 +18,7 @@ const ContributorListPage = ({loadingId, onUserClick}) => ( padding: 0, margin: 0, }}> - {ContributorListResource.read(cache).map(user => ( + {ContributorListResource.read().map(user => ( onUserClick(user.id)} diff --git a/fixtures/unstable-async/suspense/src/components/UserPage.js b/fixtures/unstable-async/suspense/src/components/UserPage.js index ce3526926bdb8..fc370bd1f9f35 100644 --- a/fixtures/unstable-async/suspense/src/components/UserPage.js +++ b/fixtures/unstable-async/suspense/src/components/UserPage.js @@ -1,7 +1,6 @@ import React, {Suspense} from 'react'; import {unstable_createResource} from 'react-cache'; import Spinner from './Spinner'; -import {cache} from '../cache'; import {fetchUserProfileJSON, fetchUserRepositoriesListJSON} from '../api'; export default function UserPage({id}) { @@ -24,7 +23,7 @@ export default function UserPage({id}) { const UserDetailsResource = unstable_createResource(fetchUserProfileJSON); function UserDetails({id}) { - const user = UserDetailsResource.read(cache, id); + const user = UserDetailsResource.read(id); return (
; + return {alt}; } function UserPicture({source}) { @@ -137,7 +136,7 @@ const UserRepositoriesResource = unstable_createResource( ); function Repositories({id}) { - const repos = UserRepositoriesResource.read(cache, id); + const repos = UserRepositoriesResource.read(id); return (
    { trace('Clear cache', performance.now(), () => { - cache.invalidate(); + // TODO: this is not implemented. + // cache.invalidate(); this.setState(state => ({ requests: {}, }));