Answer the question
In order to leave comments, you need to log in
Why is React.Context and Typescript not working?
Help file
import React from "react";
export default React.createContext({handleAddCard: (title:string) => {}});
const handleAddCard = (title:string) => {
let boardId = keysToId()
addCards(title,boardId)
}
return (
<functionApi.Provider value={{handleAddCard}}>
<Paper className={classes.listComponent}>
<Title/>
<Card/>
<Card/>
<Card/>
<Card/>
<InputContainer type='card'/>
</Paper>
</functionApi.Provider>
)
}
const handleOnChange = (event:React.ChangeEvent<HTMLInputElement>) => {
setTitle(event.target.value)
}
const handleBtnAddBoard = (event:SyntheticEvent) => {
event.preventDefault()
handleAddCard('1212')
}
return (
<div>
<div >
<Paper className={classes.card} >
<InputBase
onBlur={() => setOpen(false)}
onChange={handleOnChange}
multiline
fullWidth
placeholder={'Добавить'}
/>
</Paper>
</div>
<div className={classes.btnBlock}>
<Button
className={classes.btnSetting}
onClick={handleBtnAddBoard}
>Добавить</Button>
<IconButton onClick={() => setOpen(false)}>
<ClearIcon />
</IconButton>
</div>
</div>
)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question