Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

moved to static using query param instead of dynamic routing

awaliasaa04f6d7533c
diff --git a/examples/todo/.gitignore b/examples/todo/.gitignore
index 4d29575de80..3a9c6a59269 100644
--- a/examples/todo/.gitignore
+++ b/examples/todo/.gitignore
@@ -21,3 +21,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+
+.vercel
\ No newline at end of file
diff --git a/examples/todo/package.json b/examples/todo/package.json
index 435b3435a7d..8276090e386 100644
--- a/examples/todo/package.json
+++ b/examples/todo/package.json
@@ -16,7 +16,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
- "eject": "react-scripts eject"
+ "eject": "react-scripts eject",
+ "deploy": "react-scripts build && cd build && now --prod"
},
"eslintConfig": {
"extends": "react-app"
diff --git a/examples/todo/public/index.html b/examples/todo/public/index.html
index aa069f27cbd..cc47aca3150 100644
--- a/examples/todo/public/index.html
+++ b/examples/todo/public/index.html
@@ -1,4 +1,5 @@
<!DOCTYPE html>
+<base href="/" />
<html lang="en">
<head>
<meta charset="utf-8" />
@@ -24,7 +25,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
- <title>React App</title>
+ <title>Supabase Task List</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
diff --git a/examples/todo/src/TodoList.js b/examples/todo/src/TodoList.js
index 26ca77e94c7..ab2d951a757 100644
--- a/examples/todo/src/TodoList.js
+++ b/examples/todo/src/TodoList.js
@@ -2,10 +2,8 @@ import React, { useState } from 'react'
import { Link } from 'react-router-dom'
import { useStore, addTask, updateTask } from './Store'
-export const TodoList = (props) => {
+export const TodoList = (uuid) => {
const [newTaskText, setNewTaskText] = useState('')
- const { match } = props
- let { uuid } = match.params
const { tasks, setTasks, list } = useStore({ uuid })
return (
diff --git a/examples/todo/src/index.css b/examples/todo/src/index.css
index b5c80a98468..bf1f4fc3fe9 100644
--- a/examples/todo/src/index.css
+++ b/examples/todo/src/index.css
@@ -8,9 +8,8 @@ body {
background-color: rgb(250, 217, 246);
}
-code {
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
- monospace;
+h1 {
+ margin-bottom: 0;
}
.container {
diff --git a/examples/todo/src/index.js b/examples/todo/src/index.js
index a4628a4a799..0c202e15a02 100644
--- a/examples/todo/src/index.js
+++ b/examples/todo/src/index.js
@@ -6,25 +6,39 @@ import { TodoList } from './TodoList'
import * as serviceWorker from './serviceWorker'
import { v4 as uuidv4 } from 'uuid'
import { createList } from './Store'
+import queryString from 'query-string'
const newList = async (history) => {
const list = await createList(uuidv4())
- history.push(`/${list.uuid}`)
+ history.push(`/?uuid=${list.uuid}`)
}
-const Home = () => {
+const Home = (props) => {
const history = useHistory()
- return (
- <div className='container'>
- <button
- onClick={() => {
- newList(history)
- }}
- >
- new task list
- </button>
- </div>
- )
+ const uuid = queryString.parse(props.location.search).uuid
+
+ if (uuid) return TodoList(uuid)
+ else {
+ return (
+ <div className="container">
+ <div className="section">
+ <h1>Collaborative Task Lists</h1>
+ <small>
+ Powered by <a href="https://supabase.io">Supabase</a>
+ </small>
+ </div>
+ <div className="section">
+ <button
+ onClick={() => {
+ newList(history)
+ }}
+ >
+ new task list
+ </button>
+ </div>
+ </div>
+ )
+ }
}
render(
@@ -32,7 +46,6 @@ render(
<Router>
<Switch>
<Route exact path="/" component={Home} />
- <Route path="/:uuid" component={TodoList} />
</Switch>
</Router>
</div>,