mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
tweak(dial/nui): useContext instead of Consumer
This commit is contained in:
1 parent
ae1715f173
commit
42cdbaab4f
3 files changed
+7
-11
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import { Box, Button, Grid } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import { DialInputCtx } from '../context/InputContext';
|
||||
@@ -27,9 +27,9 @@ const ButtonItem = ({ label, onClick }: IBtnItem) => {
|
||||
};
|
||||
|
||||
export const DialGrid = () => {
|
||||
const { add, removeOne, clear} = useContext(DialInputCtx)
|
||||
|
||||
return (
|
||||
<DialInputCtx.Consumer>
|
||||
{({ add, removeOne, clear }) => (
|
||||
<Box>
|
||||
<Grid container justify='space-around'>
|
||||
<ButtonItem label={1} onClick={() => add(1)} />
|
||||
@@ -47,8 +47,6 @@ export const DialGrid = () => {
|
||||
<ButtonItem label='-' onClick={() => add('-')} />
|
||||
</Grid>
|
||||
</Box>
|
||||
)}
|
||||
</DialInputCtx.Consumer>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
import { Box, IconButton, InputBase, Paper } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
@@ -27,6 +27,8 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||
export const DialerInput = () => {
|
||||
const classes = useStyles();
|
||||
|
||||
const { inputVal } = useContext(DialInputCtx)
|
||||
|
||||
const handleCall = (number: string) => {
|
||||
Nui.send('phone:beginCall', {
|
||||
number,
|
||||
@@ -34,8 +36,6 @@ export const DialerInput = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<DialInputCtx.Consumer>
|
||||
{({ inputVal, add }) => (
|
||||
<Box component={Paper} className={classes.root}>
|
||||
<InputBase
|
||||
placeholder='Enter a number'
|
||||
@@ -46,7 +46,5 @@ export const DialerInput = () => {
|
||||
<PhoneIcon onClick={() => handleCall(inputVal)} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
)}
|
||||
</DialInputCtx.Consumer>
|
||||
);
|
||||
};
|
||||
@@ -7,7 +7,7 @@ export const callerState = {
|
||||
}),
|
||||
callModal: atom({
|
||||
key: 'callingModal',
|
||||
default: true
|
||||
default: false
|
||||
}),
|
||||
callDuration: atom({
|
||||
key: 'callDuration',
|
||||
|
||||
Reference in new issue
Block a user