-
Notifications
You must be signed in to change notification settings - Fork 236
[feat] Upgrade templates and Cookiecutter to utilize Vite, modern React + TypeScript versions #102
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
base: master
Are you sure you want to change the base?
Conversation
5a6760f
to
bbcf7dd
Compare
} | ||
|
||
const onReset = () => Streamlit.setComponentValue({}) | ||
const formik = useFormik<LoginFormValues>({ |
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.
note: I migrated this to leverage useFormik
instead of the render prop version it used before. Might be easier to review without whitespace showing.
import Typography from '@material-ui/core/Typography' | ||
import CardActions from '@material-ui/core/CardActions' | ||
import CardContent from '@material-ui/core/CardContent' | ||
import Button from "@mui/material/Button" |
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.
note: Had to update to the latest Material UI since the version it was on did not support React 18
|
||
email_field = frame.get_by_placeholder("username@domain.com") | ||
password_field = frame.get_by_placeholder("your password") | ||
invalid_username_text = frame.get_by_text("username must be a valid email") |
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.
note: The logic for when validation is run is slightly different given the formik changes
|
||
/** | ||
* This is a React-based component template. The passed props are coming from the | ||
* Streamlit library. Your custom args can be accessed via the `args` props. | ||
* A template for creating Streamlit components with 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.
note: I updated a lot of comments in this file since this is a first touchpoint for people writing custom components and I wanted it to be clearer.
useEffect(() => { | ||
Streamlit.setComponentValue(numClicks) | ||
}, [numClicks]) |
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.
note: This fixes an issue where this code wasn't following the best practices of React Hooks.
@@ -1,6 +1,3 @@ | |||
# Run the component's dev server on :3001 | |||
# (The Streamlit dev server already runs on :3000) | |||
PORT=3001 | |||
|
|||
# Don't automatically open the web browser on `npm run start`. | |||
BROWSER=none |
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.
note: Vite does not open the browser by default, so this is unnecessary
@@ -6,7 +6,7 @@ | |||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |||
<meta name="theme-color" content="#000000" /> | |||
<meta name="description" content="Streamlit Component" /> | |||
<link rel="stylesheet" href="bootstrap.min.css" /> | |||
<link rel="stylesheet" href="/bootstrap.min.css" /> |
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.
note: This change is to align with how Vite handles static asset paths
Problems:
template-reactless
templateSolutions:
createRoot
API sinceReactDOM.render
is deprecatedtemplate-reactless
template