on-internet
← Community

How to set data from a react hook inside of a function or event?

Stack Overflow ·

I'm trying to learn to create hooks so I can re-use data that I have to change in different components. I'm using Material UI's Tabs and need to use useTab, a custom hook to change the tab id. import React, { useContext } from 'react'; import { ProductsContext } from './ProductsContext'; import AppBar from '@material-ui/core/AppBar'; import Tabs from '@material-ui/core/Tabs'; import Tab from '@material-ui/core/Tab'; import { useTab } from '../../hooks/tab'; const ProductsNav = () => { const {products, categories, loading} = useContext(ProductsContext); const [tabValue] = useTab(0); const handl

Comments

Sign in or sign up to comment and upvote.

No comments yet.