Skip to content

Commit

Permalink
Fix Suspense fixture (facebook#13932)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and jetoneza committed Jan 23, 2019
1 parent d8696fa commit 33626bc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
7 changes: 0 additions & 7 deletions fixtures/unstable-async/suspense/src/cache.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -19,7 +18,7 @@ const ContributorListPage = ({loadingId, onUserClick}) => (
padding: 0,
margin: 0,
}}>
{ContributorListResource.read(cache).map(user => (
{ContributorListResource.read().map(user => (
<ContributorListItem
key={user.id}
onClick={() => onUserClick(user.id)}
Expand Down
7 changes: 3 additions & 4 deletions fixtures/unstable-async/suspense/src/components/UserPage.js
Original file line number Diff line number Diff line change
@@ -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}) {
Expand All @@ -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 (
<div
style={{
Expand Down Expand Up @@ -113,7 +112,7 @@ const ImageResource = unstable_createResource(
);

function Img({src, alt, ...rest}) {
return <img src={ImageResource.read(cache, src)} alt={alt} {...rest} />;
return <img src={ImageResource.read(src)} alt={alt} {...rest} />;
}

function UserPicture({source}) {
Expand All @@ -137,7 +136,7 @@ const UserRepositoriesResource = unstable_createResource(
);

function Repositories({id}) {
const repos = UserRepositoriesResource.read(cache, id);
const repos = UserRepositoriesResource.read(id);
return (
<ul
style={{
Expand Down
4 changes: 2 additions & 2 deletions fixtures/unstable-async/suspense/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {Fragment, PureComponent} from 'react';
import {unstable_createRoot, render} from 'react-dom';
import {unstable_trace as trace} from 'scheduler/tracing';
import {cache} from './cache';
import {
setFakeRequestTime,
setPaused,
Expand Down Expand Up @@ -66,7 +65,8 @@ class Debugger extends PureComponent {

handleReset = () => {
trace('Clear cache', performance.now(), () => {
cache.invalidate();
// TODO: this is not implemented.
// cache.invalidate();
this.setState(state => ({
requests: {},
}));
Expand Down

0 comments on commit 33626bc

Please sign in to comment.