Skip to content

Commit

Permalink
Added an example using react-aria/toast
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance committed Dec 5, 2023
1 parent 4bfa48c commit 22828d9
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/runtime/RuntimeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function useRuntime() {
const runtime = useContext(RuntimeContext);

if (isNil(runtime)) {
throw new Error("[squide] The useRuntime function is called before a Runtime instance has been provided.");
throw new Error("[squide] The useRuntime function is called before a Runtime instance has been provided. Did you forgot to ");
}

return runtime;
Expand Down
205 changes: 204 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions samples/basic/another-remote-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"dependencies": {
"@basic/shared": "workspace:*",
"@basic/shell": "workspace:*",
"@react-aria/toast": "3.0.0-beta.7",
"@react-stately/toast": "3.0.0-beta.1",
"@squide/fakes": "workspace:*",
"@squide/firefly": "workspace:*",
"react": "18.2.0",
Expand Down
2 changes: 2 additions & 0 deletions samples/basic/host/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"@basic/local-module": "workspace:*",
"@basic/shared": "workspace:*",
"@basic/shell": "workspace:*",
"@react-aria/toast": "3.0.0-beta.7",
"@react-stately/toast": "3.0.0-beta.1",
"@squide/fakes": "workspace:*",
"@squide/firefly": "workspace:*",
"react": "18.2.0",
Expand Down
4 changes: 4 additions & 0 deletions samples/basic/local-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"peerDependencies": {
"@basic/shared": "*",
"@basic/shell": "*",
"@react-aria/toast": "*",
"@react-stately/toast": "*",
"@squide/firefly": "*",
"react": "*",
"react-dom": "*",
Expand All @@ -32,6 +34,8 @@
"@squide/webpack-configs": "workspace:*",
"@swc/core": "1.3.99",
"@swc/helpers": "0.5.3",
"@react-aria/toast": "3.0.0-beta.7",
"@react-stately/toast": "3.0.0-beta.1",
"@types/react": "18.2.39",
"@types/react-dom": "18.2.17",
"@types/webpack": "5.28.5",
Expand Down
8 changes: 5 additions & 3 deletions samples/basic/local-module/src/MessagePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useApplicationEventBusDispatcher } from "@basic/shared";
import { useApplicationEventBusDispatcher, useShowToast } from "@basic/shared";
import { useCallback, useState, type ChangeEvent } from "react";
import { Link } from "react-router-dom";

Expand All @@ -10,11 +10,13 @@ export function MessagePage() {
}, []);

const dispatch = useApplicationEventBusDispatcher();
const showToast = useShowToast();

const handleSendMessage = useCallback(() => {
dispatch("write-to-host", message);
showToast(message);
setMessage("");
}, [dispatch, setMessage, message]);
}, [dispatch, showToast, setMessage, message]);

return (
<>
Expand All @@ -33,7 +35,7 @@ export function MessagePage() {
<textarea value={message} onChange={handleTextChange} />
<br />
<button type="button" onClick={handleSendMessage}>Send</button>
<p>Hint: have a look at your console log once the message has been sent :)</p>
<p>Hint: have a look at your console log and at bottom right corner of your screen once the message has been sent :)</p>
<Link to="/">Go back to home</Link>
</>
);
Expand Down
2 changes: 2 additions & 0 deletions samples/basic/remote-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"dependencies": {
"@basic/shared": "workspace:*",
"@basic/shell": "workspace:*",
"@react-aria/toast": "3.0.0-beta.7",
"@react-stately/toast": "3.0.0-beta.1",
"@squide/fakes": "workspace:*",
"@squide/firefly": "workspace:*",
"react": "18.2.0",
Expand Down
Loading

0 comments on commit 22828d9

Please sign in to comment.