From 36dc4c076c0a87fd6693a60b16d51b4a54a38a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Wed, 8 Feb 2017 13:02:17 +0100 Subject: [PATCH 1/3] [react-relay] Propagate component props to container. --- react-relay/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-relay/index.d.ts b/react-relay/index.d.ts index b238b53f77..9c45ed9c7c 100644 --- a/react-relay/index.d.ts +++ b/react-relay/index.d.ts @@ -57,7 +57,7 @@ declare module "react-relay" { supports(...options: string[]): boolean } - function createContainer(component: React.ComponentClass | React.StatelessComponent, params?: CreateContainerOpts): RelayContainerClass + function createContainer(component: React.ComponentClass | React.StatelessComponent, params?: CreateContainerOpts): RelayContainerClass function injectNetworkLayer(networkLayer: RelayNetworkLayer): any function isContainer(component: React.ComponentClass): boolean function QL(...args: any[]): string From 215f8c99ace4a0415ec0397d662a911ece84bdf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Thu, 9 Feb 2017 00:28:36 +0100 Subject: [PATCH 2/3] [react-relay] Add example of stubbing data into Relay container. --- react-relay/react-relay-tests.tsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/react-relay/react-relay-tests.tsx b/react-relay/react-relay-tests.tsx index dce5435105..ca353e1e74 100644 --- a/react-relay/react-relay-tests.tsx +++ b/react-relay/react-relay-tests.tsx @@ -41,3 +41,31 @@ export default class AddTweetMutation extends Relay.Mutation { return this.props } } + +interface ArtworkProps { + artwork: { + title: string + } +} + +class Artwork extends React.Component { + render() { + return

{this.props.artwork.title}

+ } +} + +const ArtworkContainer = Relay.createContainer(Artwork, { + fragments: { + artwork: () => Relay.QL` + fragment on Artwork { + title + } + ` + } +}) + +class StubbedArtwork extends React.Component { + render() { + return + } +} From 8c97a06d4faf943d28c6f061af61ec9f6cd0342c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Thu, 9 Feb 2017 13:02:37 +0100 Subject: [PATCH 3/3] [react-relay] Expand example to show use of `RelayProp`. --- react-relay/react-relay-tests.tsx | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/react-relay/react-relay-tests.tsx b/react-relay/react-relay-tests.tsx index ca353e1e74..7160e60b0a 100644 --- a/react-relay/react-relay-tests.tsx +++ b/react-relay/react-relay-tests.tsx @@ -45,12 +45,17 @@ export default class AddTweetMutation extends Relay.Mutation { interface ArtworkProps { artwork: { title: string - } + }, + relay: Relay.RelayProp, } class Artwork extends React.Component { render() { - return

{this.props.artwork.title}

+ return ( + + {this.props.artwork.title} + + ) } } @@ -66,6 +71,15 @@ const ArtworkContainer = Relay.createContainer(Artwork, { class StubbedArtwork extends React.Component { render() { - return + const props = { + artwork: { title: "CHAMPAGNE FORMICA FLAG" }, + relay: { + variables: { + artworkID: "champagne-formica-flag", + }, + setVariables: () => {}, + } + } + return } }