-
Notifications
You must be signed in to change notification settings - Fork 441
Add typescript support to issue-tracker #122
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
Open
renanmav
wants to merge
37
commits into
relayjs:main
Choose a base branch
from
renanmav:feat/issue-tracker-ts
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
e3bfb66
add typescript support to issue-tracker
renanmav ec59071
revert prettier config
renanmav 02ae738
replace non-null assertions for optional chaining on Root
renanmav a8424c6
throw if router doesnt exists on Link and remove unnecessary chaining…
renanmav f694d38
move RouteComponentProps to RouteRenderer
renanmav 9abf9fb
avoid braceless
renanmav 32c099d
update comment about @ts-ignore on RelayEnvironment.ts
renanmav bdb47e0
make Resource more precise
renanmav 97007ce
revert IssueListItem to IssuesListItem
renanmav e2098e2
revert README changes
renanmav 2c6a186
revert more README changes
renanmav d8411c5
revert e to event on IssueActions
renanmav 0285f0f
force rename of GitHub
renanmav dd2786c
return Suspense with null fallback inside SuspenseList
renanmav 4988da4
rename fragment IssueListItem to IssuesListItem
renanmav 927e2eb
make result either T of obj with default
renanmav f6547ee
revert disable button on IssueActions
renanmav 706cd71
revert the arrow function on Root
renanmav ab0b7ea
revert concat on RouteRenderer
renanmav 58e89a3
make prepare a mandatory function
renanmav 263a82e
use FetchFunction instead of typing function args
renanmav 6807f0c
throw this.load() func on read() JSResource
renanmav da5ec35
remove optional chaining
renanmav a0d4660
throw if there isnt a router on RouteRenderer
renanmav d621941
remove unnecessary assertions on router
renanmav 871bdca
add type guardian on JSResource
renanmav 6836fbd
make RouteConfig entry general
renanmav af5b394
revert changes on README
renanmav 7ddec0c
revert changes on README
renanmav 01baff6
use React.FC
renanmav 79e1a5e
add macro config to avoid false positive errors on yarn start
renanmav aa5def7
make all react components as React.FC
renanmav 7cd9538
Merge branch 'master' into feat/issue-tracker-ts
renanmav cc1c367
Update README.md
renanmav 5ba1807
Update .prettierrc
renanmav 71ce2bf
remove unnecessary children prop
renanmav 3d8ba57
Merge branch 'feat/issue-tracker-ts' of github.com:renanmav/relay-exa…
renanmav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "plugins": ["@babel/plugin-proposal-optional-chaining"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,26 @@ | ||
| { | ||
| "env": { | ||
| "browser": true, | ||
| "es6": true | ||
| }, | ||
| "extends": "react-app", | ||
| "plugins": [ | ||
| "prettier" | ||
| ], | ||
| "globals": { | ||
| "Atomics": "readonly", | ||
| "SharedArrayBuffer": "readonly" | ||
| }, | ||
| "parser": "@typescript-eslint/parser", | ||
| "parserOptions": { | ||
| "ecmaFeatures": { | ||
| "jsx": true | ||
| }, | ||
| "ecmaVersion": 2018, | ||
| "sourceType": "module" | ||
| }, | ||
| "plugins": ["react", "@typescript-eslint/eslint-plugin"], | ||
| "rules": { | ||
| "prettier/prettier": "error" | ||
| "indent": ["error", 2], | ||
| "linebreak-style": ["error", "unix"], | ||
| "quotes": ["error", "single"], | ||
| "semi": ["error", "always"] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,4 @@ | |
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .vscode | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "singleQuote": true, | ||
| "trailingComma": "all" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,39 +2,39 @@ | |
|
|
||
| This is an example app that implements a (partial) clone of GitHub's issue feature. The focus is on demonstrating experimental React and Relay features in the context of a real app, including Concurrent Mode, Suspense, and Relay Hooks, which are fully compatible with Concurrent Mode and Suspense out of the box. Key features include: | ||
|
|
||
| * Implementing the "render-as-you-fetch" pattern discussed in our [React Conf 2019 talk](https://youtu.be/JDDxR1a15Yo?t=3647) about Suspense for Data-Fetching as well as the [React Suspense docs](https://reactjs.org/docs/concurrent-mode-suspense.html#approach-3-render-as-you-fetch-using-suspense). During route transitions the app is configured to load the code and data for new routes *in parallel*, rendering whatever is available. | ||
| * Using Concurrent Mode and Suspense to improve the loading sequence, including [`useTransition()`](https://reactjs.org/docs/concurrent-mode-reference.html#usetransition) for route transitions in order to continue showing the previous route for a brief period while the next route is prepared/rendered. | ||
| * Uses Relay Hooks - `useFragment()` and friends - to colocate data-dependencies of components within the components themselves. | ||
| * Integrates with React Router primitives to allow preloading of code/data: this is currently a custom integration but we're working with the React Router team to implement support for preloading directly in the framework. | ||
| - Implementing the "render-as-you-fetch" pattern discussed in our [React Conf 2019 talk](https://youtu.be/JDDxR1a15Yo?t=3647) about Suspense for Data-Fetching as well as the [React Suspense docs](https://reactjs.org/docs/concurrent-mode-suspense.html#approach-3-render-as-you-fetch-using-suspense). During route transitions the app is configured to load the code and data for new routes _in parallel_, rendering whatever is available. | ||
| - Using Concurrent Mode and Suspense to improve the loading sequence, including [`useTransition()`](https://reactjs.org/docs/concurrent-mode-reference.html#usetransition) for route transitions in order to continue showing the previous route for a brief period while the next route is prepared/rendered. | ||
| - Uses Relay Hooks - `useFragment()` and friends - to colocate data-dependencies of components within the components themselves. | ||
| - Integrates with React Router primitives to allow preloading of code/data: this is currently a custom integration but we're working with the React Router team to implement support for preloading directly in the framework. | ||
|
|
||
| ## Setup | ||
|
|
||
| This app is meant for experimentation; we recommend cloning and running locally, hacking on the source code, trying to change things and see how it affects the user experience. | ||
|
|
||
| 1. First, clone the app: | ||
| 1. First, clone the app: | ||
|
|
||
| git clone [email protected]:relayjs/relay-examples.git | ||
|
|
||
| 2. Change into the app's directory: | ||
| 2. Change into the app's directory: | ||
|
|
||
| cd relay-examples/issue-tracker | ||
|
|
||
| 3. Install the app's dependencies: | ||
| 3. Install the app's dependencies: | ||
|
|
||
| # npm users: | ||
| npm install | ||
|
|
||
| # yarn users: | ||
| yarn | ||
|
|
||
| 3. Get your GitHub authentication token in order to let the app query GitHub's public GraphQL API: | ||
| a. Open https://github.com/settings/tokens. | ||
| b. Ensure that at least the `repo` scope is selected. | ||
| c. Generate the token | ||
| d. Create a file `./relay-examples/issue-tracker/.env.local` and add the following contents (substiture <TOKEN> for your authentication token): | ||
| 4. Get your GitHub authentication token in order to let the app query GitHub's public GraphQL API: | ||
| a. Open https://github.com/settings/tokens. | ||
| b. Ensure that at least the `repo` scope is selected. | ||
| c. Generate the token | ||
| d. Create a file `./relay-examples/issue-tracker/.env.local` and add the following contents (substiture <TOKEN> for your authentication token): | ||
|
|
||
| # issue-tracker/.env.local | ||
| REACT_APP_GITHUB_AUTH_TOKEN=<TOKEN> | ||
| # issue-tracker/.env.local | ||
| REACT_APP_GITHUB_AUTH_TOKEN=<TOKEN> | ||
|
|
||
| Now you're ready to run the app! | ||
|
|
||
|
|
@@ -54,12 +54,12 @@ This will start the development server (including Relay Compiler) and open a bro | |
|
|
||
| This app uses a number of technologies including (among others): | ||
|
|
||
| - [Create React App](https://github.com/facebook/create-react-app): The app has only a few additions to the default Create React App (CRA) setup - note that these all follow the CRA documentation - the app is *not* ejected: | ||
| - [Create React App](https://github.com/facebook/create-react-app): The app has only a few additions to the default Create React App (CRA) setup - note that these all follow the CRA documentation - the app is _not_ ejected: | ||
| - The app follows the steps in https://create-react-app.dev/docs/adding-relay/ to use CRA's built-in support for Relay GraphQL queries. | ||
| - The app uses CRA's support for environment variables - https://create-react-app.dev/docs/adding-custom-environment-variables - to allow configuring the GitHub authentication token. | ||
| - The app enables [prettier](https://prettier.io) for code formatting, as discussed in https://create-react-app.dev/docs/setting-up-your-editor#formatting-code-automatically. | ||
| - Note that Create React App itself builds upon many great technologies, see the docs for more details! | ||
| - React's [experimental release with Concurrent Mode and Suspense](https://reactjs.org/docs/concurrent-mode-intro.html). | ||
| - React's [experimental release with Concurrent Mode and Suspense](https://reactjs.org/docs/concurrent-mode-intro.html). | ||
| - Relay's [experimental release with Hooks and Concurrent Mode/Suspense compatibility](https://relay.dev/docs/en/experimental/a-guided-tour-of-relay). | ||
| - [React Router](https://github.com/ReactTraining/react-router) does not yet support preloading data for routes (the React Router team is working on this), so the app uses React Router's primitives instead, specifically the [`history` package](https://github.com/ReactTraining/history/) and [`react-router-config` package](https://github.com/ReactTraining/react-router/tree/master/packages/react-router-config). | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| const { useBabelRc, override } = require('customize-cra') | ||
| module.exports = override(useBabelRc()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.