I am trying to call **toggleSideBar **received in **SideBar **component as a prop. But it is giving an error that **toggleSideBar **is not a function. Actually I am trying to call toggleSideBar in another callback function
Here is the code
const Sidebar = (props) => {
const { isOpenSidebar, **toggleSideBar **} = props;
console.log(isOpenSidebar);
const closeSideBar = () => {
**toggleSideBar();**
};
2
Answers
looks like you are not passing the function correctly in the component, make sure it should be like this
Seems like you are passing function like this
Don’t call the function while passing. Make it like this