@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.
Files changed (2) hide show
  1. package/README.md +16 -14
  2. 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 to `React.mount()`.
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 React, { Tree } from "@rbxts/react";
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 { App } from "shared/ui/App";
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 _tree: Tree | undefined;
216
+ protected root: React.ReactNode | undefined;
214
217
 
215
218
  Mount() {
216
- const playerGui = Players.LocalPlayer.FindFirstChild("PlayerGui") as PlayerGui;
219
+ const playerGui = Players.LocalPlayer.FindFirstChildOfClass("PlayerGui");
217
220
 
218
- const appComponent = <App />;
219
- this._tree = React.mount(appComponent, playerGui, "App");
220
- print("App mounted");
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "UI Library and theming for roblox-ts projects",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {