@rbxts/uiblox 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ You can house all of your components within shared.
|
|
|
65
65
|
#### src/shared/ui/app/App.tsx
|
|
66
66
|
|
|
67
67
|
The top-level class for our UI. Loads the actual ApplLayout into ScreenGui. This
|
|
68
|
-
is what we later pass
|
|
68
|
+
is what we later pass when mounting the App.
|
|
69
69
|
|
|
70
70
|
```javascript
|
|
71
71
|
import React, { Component } from "@rbxts/react";
|
|
@@ -205,26 +205,28 @@ Some sample logic for mounting app when player spawns (on client).
|
|
|
205
205
|
Mount the App in the LocalPlayer's `PlayerGui`.
|
|
206
206
|
|
|
207
207
|
```javascript
|
|
208
|
-
import
|
|
208
|
+
import Log from "@rbxts/log";
|
|
209
|
+
import React, { StrictMode } from "@rbxts/react";
|
|
210
|
+
import { createPortal, createRoot } from "@rbxts/react-roblox";
|
|
209
211
|
import { Players } from "@rbxts/services";
|
|
210
|
-
import {
|
|
212
|
+
import { APP_CONTAINER_NAME } from "shared/constants/AppConstants";
|
|
213
|
+
import App from "shared/packages/ui/app/components/App";
|
|
211
214
|
|
|
212
215
|
class AppLoader {
|
|
213
|
-
protected
|
|
216
|
+
protected root: React.ReactNode | undefined;
|
|
214
217
|
|
|
215
218
|
Mount() {
|
|
216
|
-
const playerGui = Players.LocalPlayer.
|
|
219
|
+
const playerGui = Players.LocalPlayer.FindFirstChildOfClass("PlayerGui");
|
|
217
220
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
Unmount() {
|
|
224
|
-
if (this._tree) {
|
|
225
|
-
React.unmount(this._tree);
|
|
226
|
-
print("App unmounted");
|
|
221
|
+
if (!playerGui) {
|
|
222
|
+
Log.Error("PlayerGui not found");
|
|
223
|
+
return;
|
|
227
224
|
}
|
|
225
|
+
|
|
226
|
+
const root = createRoot(new Instance("Folder"));
|
|
227
|
+
|
|
228
|
+
root.render(<StrictMode>{createPortal(<App key={APP_CONTAINER_NAME} />, playerGui)}</StrictMode>);
|
|
229
|
+
Log.Info("App mounted");
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
232
|
|