mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
feat(example-app): example app for nui
This commit is contained in:
1 parent
27a0ee72b4
commit
260cda6275
4 files changed
+38
-6
No files matched your search
@@ -1,17 +1,22 @@
|
|||||||
import React from "react";
|
import React from 'react';
|
||||||
|
|
||||||
import { AppWrapper } from "../../../ui/components";
|
import { AppWrapper } from '../../../ui/components';
|
||||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||||
import { AppContent } from "../../../ui/components/AppContent";
|
import { AppContent } from '../../../ui/components/AppContent';
|
||||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||||
|
import { useExample } from '../hooks/useExample';
|
||||||
|
|
||||||
export const ExampleApp = () => {
|
export const ExampleApp = () => {
|
||||||
const example = useApp("EXAMPLE");
|
// calling the example hook, and we assign the value to a variable
|
||||||
|
const exampleString = useExample();
|
||||||
|
const example = useApp('EXAMPLE');
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle app={example} />
|
<AppTitle app={example} />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
<h1>This is an example</h1>
|
<h1>This is an example</h1>
|
||||||
|
{/* Here we are using the value in a h3 tag */}
|
||||||
|
<h3>{exampleString}</h3>
|
||||||
</AppContent>
|
</AppContent>
|
||||||
</AppWrapper>
|
</AppWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { atom } from 'recoil';
|
||||||
|
|
||||||
|
export const exampleState = {
|
||||||
|
example: atom({
|
||||||
|
key: 'exampleState',
|
||||||
|
default: null,
|
||||||
|
}),
|
||||||
|
};
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { useRecoilValue } from 'recoil';
|
||||||
|
import { exampleState } from './state';
|
||||||
|
|
||||||
|
export const useExample = () => {
|
||||||
|
const example = useRecoilValue(exampleState.example);
|
||||||
|
return example;
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||||
|
import { useSetRecoilState } from 'recoil';
|
||||||
|
import { exampleState } from './state';
|
||||||
|
import { useExample } from './useExample';
|
||||||
|
|
||||||
|
export const useExampleService = () => {
|
||||||
|
const setExample = useSetRecoilState(exampleState.example);
|
||||||
|
useNuiEvent('EXAMPLE', 'setExample', setExample);
|
||||||
|
return useExample();
|
||||||
|
};
|
||||||
|
|
||||||
|
// call this function in the Phone.tsx file.
|
||||||
Reference in new issue
Block a user