score:0
Accepted answer
class parentcomponent extends component {
passedfunction = () => {}
render() {
<childcomponent passedfunction={this.passedfunction}/>
}
}
class childcomponent extends component {
render() {
<div onclick={this.props.passedfunction}></div>
}
}
you can use arrow function to avoid all the bindings. if you want to bind it, bind it in the constructor like so... in the parent component.
constructor() {
this.passedfunction = this.passedfunction.bind(this)
}
<childcomponent passedfunction={this.passedfunction}/>
i could see that, in your child component you are using :
update(){
console.log("updating...");
this.props.updatecolumn("test","test");
}
but your props for that function is colupdate i.e. you should be using
update(){
console.log("updating...");
this.porps.colupdate("test","test");
}
hope this helps!
Source: stackoverflow.com
Related Query
- React how to send method to childComponent
- How to send token through headers by using axios post method in react
- How to send object to through axios get method from react to .NET API?
- How to send an onClick event using renderToString method in React
- how to send cookies with axios post method using react Js
- How to unit test a method of react component?
- How to send request on click React Hooks way?
- How do I store JWT and send them with every request using react
- How can I call parent method in a child React component?
- How can I speed up a React render() method that generates a huge DOM?
- React Native: How to export a method with a return value?
- How to send params in useHistory of React Router Dom?
- How to unit test React Component shouldComponentUpdate method
- How to use onChange method in semantic react dropdown
- React - How to iterate over dictionary in render method using JSX?
- How to test properly React Dropzone onDrop method
- How do I send custom data in react-router goBack method like push and replace methods?
- how to send email directly in React Native App
- How to provide dynamic className to element in React Class render method
- React Typescript how send props and use it in child component
- How can we send OAuth2.0 with axios in React js
- How to send form data from React to express
- How to mock a React component lifecycle method with Jest and Enzyme?
- How do i call a method within another method in react class Es6
- How To Declare TypeScript Static Method From React Functional Component
- React router 4: How to wait for a promise to resolve, inside render method of Route?
- How to test React state after calling a component method that updates state - using Enzyme
- How to send email from my react web application
- How to bind "this" for react component method
- How do I embed a facebook send button in my react app?
More Query from same tag
- Pull to Refresh and setState not working - React Native
- How to programmatically expand or collapse Tree Item in Material Ui?
- React-native, use fullscreen image on android
- Create-react-app fires up from terminal but not vs-code
- Detect Route Change with react-router
- React/Jest Select element onChange values not updating
- React url changes but component state the same
- Why does table headers and data overlap in Ant table if some columns are fixed in some browsers?
- How to change each word color in react content
- React map with opening and closing tags
- React-router did not work on production
- css responsive flex layout column to row
- Pass props to a child component in React
- useHistory - Cannot read property 'push' of undefined
- Redirect 404 to homepage in Nextjs with dynamic routes
- How can I add an icon to Material UI Select options?
- shuffle function called every time state is updated?
- React eliminate dots from import
- How to stop error 'Cannot read property 'gender' of null'?
- MongooseError [OverwriteModelError]: Cannot overwrite `Team` model once compiled
- Module build failed: ReferenceError: [BABEL]
- Jest Unit testing onClick event
- How do I know if I am inside a React router?
- Redirecting willTransitionTo in react-router 2.4.0?
- Check if Array has all ID values from another Array of Objects ( ReactJS )
- useParams and useEffect, Parameter via ${id} in the useEffect function
- How to load custom script in react?
- Using percent ( % ) sign in react-router :id
- Relay mutation on plain array is not working
- ReactJs 0.14 - TreeView