score:6
Accepted answer
you could use a ref to call the child close function?
parent
removeitem() {
console.log('clicked');
this.child.close();
}
render() {
return (
<div>
<childwithmodal ref={(ref) => { this.child = ref; }} />
</div>
);
}
child
...
close() {
this.setstate({ showmodal: false })
};
Source: stackoverflow.com
Related Query
- React: Closing Modal in Child Component from Parent
- React - set state of parent component to close modal from a child component
- Closing react-bootstrap popup modal by passing function from parent component to child component via props not updating state
- React js change child component's state from parent component
- React Hook : Send data from child to parent component
- Updating Parent Component State from Child Component with UseState React Hook
- passing data from child to parent component - react - via callback function
- Why is child component not receiving updated value from parent in React Native?
- React | pass data from parent to child component
- React: How to close a modal from child opened from parent component
- Sharing state from parent to child component in React
- Can't call child component method from parent component in React Native
- How to pass input value from child to parent component react
- Access child state of child from parent component in react
- Trigger child function from parent component using react hooks
- Pass an object from child to parent component in React
- How to communicate from Child Component to Parent Component with React Router
- Passing API data from parent container to child component in React
- Updating Child Component Via Change of Props from Parent in React
- How to update parent state from child component in React + send a paramater
- How is an argument for a callback in React being passed from the child component to the parent component?
- React child component not rendering props from parent value
- Wait for change of prop from parent component after changing it from a child in React
- pass async results from parent to child component react functional component
- How to pass an Array from Child component to Parent component in react I know how to pass from parent t
- Refresh a React Child Functional Component based on Async input from Parent
- Calling an event handler defined in parent from child component in React
- Remove a child component from parent dom node in react
- React TS - How to pass props from a parent component to a deeply nested child
- How to trigger an event in Parent Component from Child Component onClick() using React Hooks?
More Query from same tag
- how do we push a checkbox to an array while checkbox is by default checked in react js?
- React component not re-rendering after props change
- Server side rendering with react, react-router, and express
- How to make my element take 100% of the screen width even if it is inside an element that take 80% of the screen?
- How can i dynamically assign the props as variables to colors from my own color pallet in scss/css with react?
- Load Material UI AutoComplete suggestions after user input
- TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'
- onChange useState one character behind
- Load third party iframe in React after page load, so that the iframe does not affect PageSpeed score
- Removing console.log in production React JS with WebPack / Babel
- I need to render a JSX element in Material-ui DataGrid
- convert all keys of object to variable in ReactJS
- Match API and isomorphic routes
- How to cancel socket.io-client subscription in react
- Typescript Error in React useScroll hook: Cannot invoke an expression whose type lacks a call signature
- React Hook Form - Controller - React AsyncSelect - Lodash Debounce | Failed showing loadOptions
- Material UI and React: prevent popup of Autocomplete to close when focusing on a child input
- Vertically center radio button - React and Bootstrap
- How to display data with div tag inside an array in react js?
- Plugin not defined in webpack configuration file
- State is getting input from user but not displaying on webpage in React.js
- Material-UI Typography doesn't center in AppBar
- Why do I get Method “props” is only meant to be run on a single node. 0 found instead in unit testing?
- Error when deploying react app and it keeps sayings << Plugin "react" was conflicted between "package.json » eslint-config-react-app » >>
- React Material UI- make a button open a file picker window
- Errors show correctly on Graphiql but not returned to Apollo Client in react front end
- Why is the JavaScript spread notation not working here
- How can query params be pushed and used for this page in react?
- Socket IO emit events twice
- React JS inherit functionally to several components