Skip to content

Commit c512aa0

Browse files
maisanogaearon
andauthored
[Blocks] Scaffolding react-fetch + first pass at node implementation (facebook#18863)
* First pass at scaffolding out the Node implementation of react-data. While incomplete, this patch contains some changes to the react-data package in order to start adding support for Node. The first part of this change accounts for splitting react-data/fetch into two discrete entries, adding (and defaulting to) the Node implementation. The second part is sketching out a rough approximation of `fetch` for Node. This implementation is not complete by any means, but provides a starting point. * Remove NodeFetch module and put it directly into ReactDataFetchNode. * Replaced react-data with react-fetch. This patch shuffles around some of the scaffolding that was in react-data in favor of react-fetch. It also removes the additional "fetch" package in favor of something flatter. * Tweak package organization * Simplify and add a test Co-authored-by: Dan Abramov <dan.abramov@me.com>
1 parent e936034 commit c512aa0

24 files changed

+376
-70
lines changed

fixtures/blocks/src/server/Comments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* eslint-disable import/first */
88

99
import * as React from 'react';
10-
import {fetch} from 'react-data/fetch';
10+
import {fetch} from 'react-fetch';
1111

1212
// TODO: Replace with asset reference.
1313
import Link from '../client/Link';

fixtures/blocks/src/server/Feed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* eslint-disable import/first */
88

99
import * as React from 'react';
10-
import {fetch} from 'react-data/fetch';
10+
import {fetch} from 'react-fetch';
1111
import PostList from './PostList';
1212

1313
export default function Feed() {

fixtures/blocks/src/server/PostList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import * as React from 'react';
1010
import {Suspense, unstable_SuspenseList as SuspenseList} from 'react';
11-
import {preload} from 'react-data/fetch';
11+
import {preload} from 'react-fetch';
1212
import PostGlimmer from './PostGlimmer';
1313
import Post from './Post';
1414

fixtures/blocks/src/server/ProfileBio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* eslint-disable import/first */
88

99
import * as React from 'react';
10-
import {fetch} from 'react-data/fetch';
10+
import {fetch} from 'react-fetch';
1111

1212
export default function ProfileBio({userId}) {
1313
const user = fetch(`/users/${userId}`).json();

fixtures/blocks/src/server/ProfilePage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import * as React from 'react';
99
import {Suspense} from 'react';
10-
import {fetch} from 'react-data/fetch';
10+
import {fetch} from 'react-fetch';
1111
import {matchRoute} from './ServerRouter';
1212
import ProfileTimeline from './ProfileTimeline';
1313
import ProfileBio from './ProfileBio';

fixtures/blocks/src/server/ProfileTimeline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/* eslint-disable import/first */
88

99
import * as React from 'react';
10-
import {fetch} from 'react-data/fetch';
10+
import {fetch} from 'react-fetch';
1111
import PostList from './PostList';
1212

1313
export default function ProfileTimeline({userId}) {

packages/react-data/npm/fetch.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/react-data/npm/index.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/react-data/src/__tests__/ReactDataFetch-test.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/react-data/README.md renamed to packages/react-fetch/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# react-data
1+
# react-fetch
22

33
This package is meant to be used alongside yet-to-be-released, experimental React features. It's unlikely to be useful in any other context.
44

0 commit comments

Comments
 (0)