Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Suspense fixture #13932

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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