-
Notifications
You must be signed in to change notification settings - Fork 189
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
Port Spinner from Gatsby to Next.js(TS) #1462
Conversation
@@ -0,0 +1,54 @@ | |||
import React, { FC, FormEvent, useState } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this thread:
Next.js automatically adds the React import when JSX is used indeed. However keep in mind that we do still need to import React from 'react' when the React variable is used.
type SearchPageProps = { | ||
text: string; | ||
filter: string; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type SearchPageProps = { | |
text: string; | |
filter: string; | |
}; | |
interface SearchPageProps { | |
text: string | null; | |
filter: string | null; | |
}; |
whoops, sorry. Accidentally clicked that button. |
@c3ho could you rebase this for package.json changes? |
src/frontend/next/package.json
Outdated
"react-dom": "^16.13.1" | ||
"react-dom": "^16.13.1", | ||
"swr": "^0.3.9", | ||
"use-query-params": "^1.1.9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these are already merged into next now
import { FC } from 'react'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import CircularProgress from '@material-ui/core/CircularProgress'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
root: { | ||
display: 'flex', | ||
'& > * + *': { | ||
marginLeft: theme.spacing(2), | ||
}, | ||
}, | ||
})); | ||
|
||
const Spinner: FC = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { FC } from 'react'; | |
import { makeStyles } from '@material-ui/core/styles'; | |
import CircularProgress from '@material-ui/core/CircularProgress'; | |
const useStyles = makeStyles((theme) => ({ | |
root: { | |
display: 'flex', | |
'& > * + *': { | |
marginLeft: theme.spacing(2), | |
}, | |
}, | |
})); | |
const Spinner: FC = () => { | |
import { makeStyles } from '@material-ui/core/styles'; | |
import CircularProgress from '@material-ui/core/CircularProgress'; | |
const useStyles = makeStyles((theme) => ({ | |
root: { | |
display: 'flex', | |
'& > * + *': { | |
marginLeft: theme.spacing(2), | |
}, | |
}, | |
})); | |
const Spinner = () => { |
AFAIK we don't need to import FC
@@ -0,0 +1,54 @@ | |||
import { FC, FormEvent, useState } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { FC, FormEvent, useState } from 'react'; | |
import { FormEvent, useState } from 'react'; |
}, | ||
})); | ||
|
||
const SearchPage: FC = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const SearchPage: FC = () => { | |
const SearchPage = () => { |
// via `textParam` and `filterParam`. The <SearchBar> UI uses our internal | ||
// state values, and the <SearchResults> only update on page load or when | ||
// the user submits the form. | ||
const [textParam = '', setTextParam] = useQueryParam('text', StringParam); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I merged in the current master to this pr and I'm getting errors when trying to render <SearchPage />
:
Error: useQueryParams must be used within a QueryParamProvider
Got any ideas?
@@ -0,0 +1,85 @@ | |||
import { FC } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { FC } from 'react'; |
}, | ||
})); | ||
|
||
const SearchResults: FC<SearchPageProps> = ({ text, filter }: SearchPageProps) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const SearchResults: FC<SearchPageProps> = ({ text, filter }: SearchPageProps) => { | |
const SearchResults = ({ text, filter }: SearchPageProps) => { |
if (error) { | ||
return ( | ||
<Container className={classes.searchResults}> | ||
<Box className={classes.root} boxShadow={2} marginTop={10}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting Property 'root' does not exist on type 'Record<"spinner" | "searchResults", string>'.
with the latest master merge, same with line 52 and 53.
But I'm getting No search results
when rendering the component so I think it's fine.
So that was a lot, to the point where I feel like I might be doing something wrong on my end, haha. Let me know what you think, plz n thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍
Issue This PR Addresses
Fixes #1479
Type of Change
Description
Porting from Gatsby to Next JS + changing JS to TS for the
Spinner
component.Checklist