forked from remix-run/remix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formatted cca6628
- Loading branch information
Remix Run Bot
committed
Jan 8, 2022
1 parent
cca6628
commit 81dd8f0
Showing
12 changed files
with
79 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,31 +1,32 @@ | ||
|
||
import { json, LoaderFunction, useLoaderData } from "remix" | ||
import type { LoaderFunction} from "remix"; | ||
import { json, useLoaderData } from "remix"; | ||
import { commitSession, getSession } from "~/sessions.server"; | ||
|
||
export const loader: LoaderFunction = async ({request}) => { | ||
export const loader: LoaderFunction = async ({ request }) => { | ||
// Get the session from the cookie | ||
const session = await getSession(request.headers.get("Cookie")); | ||
const myStoredData = session.get('myStoredData'); | ||
const myStoredData = session.get("myStoredData"); | ||
// If no session found (was never created or was expired) create a new session. | ||
if (!myStoredData) { | ||
session.set('myStoredData', 'Some data'); | ||
session.set("myStoredData", "Some data"); | ||
return json( | ||
{ | ||
message: "Created new session", | ||
message: "Created new session" | ||
}, | ||
{ | ||
headers: { | ||
"Set-Cookie": await commitSession(session), | ||
}, | ||
} ) | ||
"Set-Cookie": await commitSession(session) | ||
} | ||
} | ||
); | ||
} | ||
// If session was found, present the session info. | ||
return json({ | ||
message: `Showing Session info: ${myStoredData}` | ||
}) | ||
} | ||
message: `Showing Session info: ${myStoredData}` | ||
}); | ||
}; | ||
|
||
export default function() { | ||
const data = useLoaderData() | ||
return <div>{data.message}</div> | ||
} | ||
export default function () { | ||
const data = useLoaderData(); | ||
return <div>{data.message}</div>; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,3 +1,3 @@ | ||
export default function Index() { | ||
return <h1 className="text-6xl text-red-700 font-bold">Hello World!</h1>; | ||
} | ||
return <h1 className="text-6xl text-red-700 font-bold">Hello World!</h1>; | ||
} |
This file contains 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,7 +1,7 @@ | ||
module.exports = { | ||
content: ["./app/**/*.{ts,tsx,js,jsx}"], | ||
theme: { | ||
extend: {}, | ||
extend: {} | ||
}, | ||
plugins: [], | ||
} | ||
plugins: [] | ||
}; |