score:2
if you have nested components you can call the other one's function like so:
child:
var component1 = react.createclass({
render: function() {
return (
<div><button onclick={this.props.callback}>click me</button></div>
)
}
})
parent:
var component2 = react.createclass({
dosomethinginparent: function() {
console.log('i called from component 2');
},
render: function() {
return (
<div><component1 callback={this.dosomethinginparent} /></div>
)
}
})
same goes in your case. it wasn't very clear in your code so i couldn't help you with the code itself. if you get messy with this please post your entire code in a hierarchically way so it'll be more readable.
Source: stackoverflow.com
Related Query
- Call a React component method from outside
- Call a React component method from outside
- Can't call child component method from parent component in React Native
- React-bootstrap call method of external component
- Can you add an external function as a method in a React component class?
- How does one React component call a method in another React component?
- Call child component method from parent in react
- How to pass an external method to a stateless functional component in React
- React/ES6 -> How to call an React component class method from another component?
- React + Redux - Call a method of a component wrapped for the Redux Provider
- call instance method from higher order component in react
- Call React component method from within setTimeout
- How to call child component's method from a parent component in React
- Call a method within a React Component from Electron's globalShortcut
- React - call parent method in child component after passing it
- React error: call child method in parent component
- When testing a React component with Enzyme is it better to use simulate or to call the method directly on the instance()?
- React Recompose call a bound method of an enhaced component
- React call parent component method from child component method
- How to call a method of a React component inside mounted Provider in test
- Getting invalid hook call error in React when I used materidal design bootstrap component in my application
- React - Dont call method if event is fired from an element currently rendered by this component
- React - Call parent method from within child component
- how do you call a method from another react class component
- Not able to call the the method of the child component in react
- React life cycle method for making API call when component is re-rendered
- How to call service class method from functional component in react
- How to call method of React component outside of a class?
- Call a method pass from parent component to child component in React
- Call Method that inside Another Component - React Js
More Query from same tag
- Make checked/unchecked attribute onChange checkbox in Reactjs
- react-simple-maps Renders map upside down
- How to pass the dynamic created props to the component?
- Access all files within a given folder (The File System Access API)
- React infinite render loop
- Redux with React - right way to share the store with components
- App crashed when I try to map through and render data in React
- Enabling CORS with openapi-generator
- Two form's error message handling on same page in react.js
- Must specify either a render prop, a render function as children, or a component prop to Field(auto)
- React testing library not work with react router v6
- How to add min to redux form field
- How to cancel TextInput's onChange event when loading a file?
- Is there a way to fully encapsulate React from the Window object
- How to keep text in same position?
- how to change hover for all elements ( border, text and arrow ) in react-select?
- Im trying to encrypt the password in REACT so that every letter will printout as asterisk ` * `
- How to change Legend text colors in recharts
- React redux-strange behavior, prevState and newState change together
- .Net cors policy issue
- Best practices for async await when retrieving data from firestore
- React-Redux: How to ensure that multiple fetch requests are all successfully made before an action is dispatched
- Making interface accept multiple possibilities
- React useMemo memory clean
- Extend a Styled Component from a different file
- React, variable speed Clock with setTimeout
- React + Chai + Enzyme
- How can I reuse a component with different props in React?
- React + Redux, where should my UI-related calculations go, container components, or reducers?
- Hide Material-UI Autocomplete popup until text is typed