ISSUE-032 - Found a fix to the Hooks rendering error by using ReactRouter.
This commit is contained in:
1 parent
e676c7a95a
commit
f9f7b739ee
8 files changed
+38
-42
No files matched your search
@@ -22,7 +22,7 @@ export function SlotSelector({
|
|||||||
const [prefixMask, setPrefixMask] = useState(0);
|
const [prefixMask, setPrefixMask] = useState(0);
|
||||||
const [formattedItems, setFormattedItems] = useState<Array<string>>([]);
|
const [formattedItems, setFormattedItems] = useState<Array<string>>([]);
|
||||||
|
|
||||||
// useMemo makes these functions only run once when mounting. Not ever re-render.
|
// useMemo makes these functions only run once when mounting. Not every re-render.
|
||||||
useMemo(() => {
|
useMemo(() => {
|
||||||
const tempFormattedItems = items.map(item => formatter(item));
|
const tempFormattedItems = items.map(item => formatter(item));
|
||||||
setFormattedItems(tempFormattedItems);
|
setFormattedItems(tempFormattedItems);
|
||||||
@@ -39,7 +39,7 @@ export function SlotSelector({
|
|||||||
formattedItems.length &&
|
formattedItems.length &&
|
||||||
removePrefix &&
|
removePrefix &&
|
||||||
formattedItems[0].length !== prefixMask ?
|
formattedItems[0].length !== prefixMask ?
|
||||||
formattedItems[i].slice(prefixMask) :
|
formattedItems[i]?.slice(prefixMask) ?? undefined :
|
||||||
formattedItems[i];
|
formattedItems[i];
|
||||||
|
|
||||||
const transRef = useSpringRef();
|
const transRef = useSpringRef();
|
||||||
|
|||||||
+1
@@ -11,6 +11,7 @@ const countries = [
|
|||||||
"GBR", "NLD", "FIN", "JPN", "FRA", "DEU", "MEX", "POL", "MCO", "CHN", "THA",
|
"GBR", "NLD", "FIN", "JPN", "FRA", "DEU", "MEX", "POL", "MCO", "CHN", "THA",
|
||||||
"CAN", "RUS", "RAF", "AUS", "ESP", "ITA",
|
"CAN", "RUS", "RAF", "AUS", "ESP", "ITA",
|
||||||
];
|
];
|
||||||
|
|
||||||
export function AngledFlagPrototypeControls() {
|
export function AngledFlagPrototypeControls() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { prototypeState } = useSelector(workspaceSelector);
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { Route, Routes, useParams } from "react-router-dom";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Center } from "@bedrock-layout/center";
|
import { Center } from "@bedrock-layout/center";
|
||||||
import { Stack } from "@bedrock-layout/stack";
|
import { Stack } from "@bedrock-layout/stack";
|
||||||
@@ -10,14 +10,14 @@ import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSe
|
|||||||
import { newWorkspace } from "../../../features/overlayTool/overlayToolSlice";
|
import { newWorkspace } from "../../../features/overlayTool/overlayToolSlice";
|
||||||
|
|
||||||
import { PreviewWindow, H2, ControlsContainer } from "./styles";
|
import { PreviewWindow, H2, ControlsContainer } from "./styles";
|
||||||
import { WorkspaceControls } from "./WorkspaceControls/WorkspaceControls";
|
import { WorkspaceControls } from "../WorkspaceControls";
|
||||||
import { OverlayDisplay } from "../../OverlayTool";
|
import { OverlayDisplay } from "../../OverlayTool";
|
||||||
|
|
||||||
import { fetchBroadcastGraphic, workspaces } from "../../../domain/data/workspaces";
|
import { workspaces } from "../../../domain/data/workspaces";
|
||||||
|
|
||||||
export const Workspace = () => {
|
export const Workspace = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { workspaceId } = useParams();
|
const { "*": workspaceId } = useParams();
|
||||||
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
const { animatedBG, workspaceProperties } = useSelector(workspaceSelector);
|
||||||
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
const { currentWorkspaceId: overlayWorkspaceId } = useSelector(overlayToolSelector);
|
||||||
|
|
||||||
@@ -41,7 +41,6 @@ export const Workspace = () => {
|
|||||||
|
|
||||||
if (workspaceId == null) return null;
|
if (workspaceId == null) return null;
|
||||||
|
|
||||||
const [graphic, controls] = fetchBroadcastGraphic(workspaceId);
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gutter="lg"
|
gutter="lg"
|
||||||
@@ -54,15 +53,37 @@ export const Workspace = () => {
|
|||||||
dimensions={workspaceProperties.previewWindowDimensions}
|
dimensions={workspaceProperties.previewWindowDimensions}
|
||||||
animatedBG={animatedBG}
|
animatedBG={animatedBG}
|
||||||
>
|
>
|
||||||
{graphic}
|
<PreviewContent />
|
||||||
<OverlayDisplay
|
<OverlayDisplay
|
||||||
containerDimensions={workspaceProperties.previewWindowDimensions}
|
containerDimensions={workspaceProperties.previewWindowDimensions}
|
||||||
/>
|
/>
|
||||||
</PreviewWindow>
|
</PreviewWindow>
|
||||||
<ControlsContainer>
|
<ControlsContainer>
|
||||||
<WorkspaceControls />
|
<WorkspaceControls />
|
||||||
{controls}
|
<PrototypeControls />
|
||||||
</ControlsContainer>
|
</ControlsContainer>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
import { ChyronDriver } from "../../BroadcastGraphics/Chyrons/Driver";
|
||||||
|
import { AngledFlagWorkSpace } from "../CustomWorkSpaces/AngledFlagWorkSpace";
|
||||||
|
import { ChyronPrototypeControls } from "../PrototypingControls/ChyronPrototype";
|
||||||
|
import { AngledFlagPrototypeControls } from "../PrototypingControls/AngledFlagPrototype";
|
||||||
|
|
||||||
|
const PreviewContent = () => (
|
||||||
|
<Routes>
|
||||||
|
<Route path="chyronDriver" element={<ChyronDriver />} />
|
||||||
|
<Route path="angledFlag" element={<AngledFlagWorkSpace />} />
|
||||||
|
<Route path="*" element={null} />
|
||||||
|
</Routes>
|
||||||
|
);
|
||||||
|
|
||||||
|
const PrototypeControls = () => (
|
||||||
|
<Routes>
|
||||||
|
<Route path="chyronDriver" element={<ChyronPrototypeControls />} />
|
||||||
|
<Route path="angledFlag" element={<AngledFlagPrototypeControls />} />
|
||||||
|
<Route path="*" element={null} />
|
||||||
|
</Routes>
|
||||||
|
);
|
||||||
+4
-4
@@ -2,11 +2,11 @@ import { Grid } from "@bedrock-layout/grid";
|
|||||||
import { PadBox } from "@bedrock-layout/padbox";
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
||||||
import { setAnimatedBG } from "../../../../features/workspace/workspaceSlice";
|
import { setAnimatedBG } from "../../../features/workspace/workspaceSlice";
|
||||||
|
|
||||||
import { Toggle } from "../../../Common/Inputs/Toggle";
|
import { Toggle } from "../../Common/Inputs/Toggle";
|
||||||
import { OverlayControl } from "../../../OverlayTool";
|
import { OverlayControl } from "../../OverlayTool";
|
||||||
|
|
||||||
export const WorkspaceControls = () => {
|
export const WorkspaceControls = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./WorkspaceControls";
|
||||||
@@ -18,7 +18,7 @@ export const WorkspaceList = ({ headerOffset }: WorkspaceListProps) => {
|
|||||||
{workspaceList.map((id) => (
|
{workspaceList.map((id) => (
|
||||||
<WorkspaceListNavLink
|
<WorkspaceListNavLink
|
||||||
key={id}
|
key={id}
|
||||||
to={id}
|
to={`s/${id}`}
|
||||||
label={workspaces[id].name}
|
label={workspaces[id].name}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
import { ReactNode } from "react";
|
|
||||||
import { WorkspaceId, WorkspaceProperties } from "../../types/state";
|
import { WorkspaceId, WorkspaceProperties } from "../../types/state";
|
||||||
|
|
||||||
// Broadcast Graphics
|
|
||||||
import { ChyronDriver } from "../../components/BroadcastGraphics/Chyrons/Driver";
|
|
||||||
import { ChyronPrototypeControls } from "../../components/Workspaces/PrototypingControls/ChyronPrototype";
|
|
||||||
import { AngledFlagWorkSpace } from "../../components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace";
|
|
||||||
import { AngledFlagPrototypeControls } from "../../components/Workspaces/PrototypingControls/AngledFlagPrototype";
|
|
||||||
|
|
||||||
type WorkspaceObject = {
|
type WorkspaceObject = {
|
||||||
[id: WorkspaceId]: WorkspaceProperties,
|
[id: WorkspaceId]: WorkspaceProperties,
|
||||||
};
|
};
|
||||||
@@ -44,24 +37,4 @@ export const workspaces: WorkspaceObject = {
|
|||||||
height: 500,
|
height: 500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
foo: {
|
|
||||||
name: "Foo",
|
|
||||||
overlayIds: [],
|
|
||||||
previewWindowDimensions: { width: 500, height: 500 },
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function fetchBroadcastGraphic(workspaceId?: WorkspaceId): [ReactNode, ReactNode] {
|
|
||||||
switch(workspaceId) {
|
|
||||||
case "chyronDriver": return [
|
|
||||||
ChyronDriver(),
|
|
||||||
ChyronPrototypeControls(),
|
|
||||||
];
|
|
||||||
case "angledFlag": return [
|
|
||||||
AngledFlagWorkSpace(),
|
|
||||||
AngledFlagPrototypeControls(),
|
|
||||||
];
|
|
||||||
default: return [null, null];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+1
-1
@@ -28,7 +28,7 @@ ReactDOM.render(
|
|||||||
<Route path="broadcast" element={<Broadcast />} />
|
<Route path="broadcast" element={<Broadcast />} />
|
||||||
<Route path="workspaces" element={<Workspaces />}>
|
<Route path="workspaces" element={<Workspaces />}>
|
||||||
<Route index element={<h1>Workspaces Home</h1>} />
|
<Route index element={<h1>Workspaces Home</h1>} />
|
||||||
<Route path=":workspaceId" element={<Workspace />} />
|
<Route path="s/*" element={<Workspace />} />
|
||||||
</Route>
|
</Route>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="*" element={<h1>Page Not Found</h1>} />
|
<Route path="*" element={<h1>Page Not Found</h1>} />
|
||||||
|
|||||||
Reference in new issue
Block a user