mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
tweak(dial/nui): useContext instead of Consumer
This commit is contained in:
1 parent
ae1715f173
commit
42cdbaab4f
3 files changed
+34
-38
No files matched your search
@@ -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,19 +36,15 @@ export const DialerInput = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<DialInputCtx.Consumer>
|
||||
{({ inputVal, add }) => (
|
||||
<Box component={Paper} className={classes.root}>
|
||||
<InputBase
|
||||
placeholder='Enter a number'
|
||||
className={classes.input}
|
||||
value={inputVal}
|
||||
/>
|
||||
<IconButton className={classes.iconBtn}>
|
||||
<PhoneIcon onClick={() => handleCall(inputVal)} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
)}
|
||||
</DialInputCtx.Consumer>
|
||||
<Box component={Paper} className={classes.root}>
|
||||
<InputBase
|
||||
placeholder='Enter a number'
|
||||
className={classes.input}
|
||||
value={inputVal}
|
||||
/>
|
||||
<IconButton className={classes.iconBtn}>
|
||||
<PhoneIcon onClick={() => handleCall(inputVal)} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user