Want to type an exported RelayContainer in React? Use the Relay Compiler generates Flow types for the fragment and these are exported in generated files within a __generated__ subdirectory. relay-compiler --src ./src --schema ./schema.json
You would then import the flow types for the field props like so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import type { MyComponent_myField } from "./__generated__/MyComponent_myField.graphql"; class MyComponent extends Component<{ myField: MyComponent_myField, }> { render() { return <div>Example</div>; } } export default createFragmentContainer(MyComponent, { myField: graphql` fragment MyComponent_myField on MyType { edges { node { _id foo } } } ` }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.