Linked Questions
114 questions linked to/from Call child method from parent
1
vote
2
answers
2k
views
Functional React: call function from imported component [duplicate]
I want to call a function from a imported component in my parent react component.
My parent component:
import Customer from './Customer';
function App() {
return (
<div className="App"&...
1
vote
1
answer
6k
views
How to display a react-bootstrap modal from another component [duplicate]
I have a Meteor+React application which I'm developing where I want to implement the login/registration functionality in a modal. I'm not sure how to open the modal from clicking my sign up or log in ...
1
vote
1
answer
711
views
React: this.reference.current is null when "componentDidMount" is called [duplicate]
I'm trying to access this.myref.current, but I can't do it when componentDidMount is called. Is there another function I can call that acts when all references are linked?
Note that the issue isn't ...
2
votes
0
answers
350
views
ReactJS - How to expose your Component to external events? [duplicate]
I have two components - <Parent/> and <Book />
<Book /> is a (hopefully) re-usable component that I've written that manages its own state.
class Book extends React.component {
...
1
vote
1
answer
284
views
Invoke nested child method using refs reactJS WithStyles [duplicate]
I am trying to access a method in a nested chilld component using refs. This is to delete data in the nested delete component. My code is as follows (simplified code):
Parent Class:
class Parent ...
0
votes
1
answer
166
views
How can a parent element invoke a function defined on a child element? [duplicate]
If I have a class-based component:
class MyComponent extends React.Component {
state = {...}
constructor(props) {...}
functionIWantToCall() {...}
render() {...}
}
That is incorporated ...
0
votes
1
answer
131
views
How can I use a function from another class in my React app? [duplicate]
This is my Tools.js
export default class Tools extends React.Component {
show() {
console.log(1)
}
}
And this is my App.js
export default class App extends React.Component {
...
92
votes
4
answers
100k
views
Reactjs: how to modify dynamic child component state or props from parent?
I'm essentially trying to make tabs in react, but with some issues.
Here's file page.jsx
<RadioGroup>
<Button title="A" />
<Button title="B" />
</RadioGroup>
When you ...
14
votes
5
answers
35k
views
Call child component method from parent component in reactjs
I have requirement to call child component method from parent component
in reactjs. I have tried using refs but not able to do it. Can anyone please suggest any solution.
Thanks.
14
votes
2
answers
15k
views
Call methods on React children components
I want to write a Form component that can export a method to validate its children. Unfortunately a Form does not "see" any methods on its children.
Here is how I define a potential children of Form:
...
5
votes
5
answers
19k
views
Is there a way to call a child's function from parent in React?
I was wondering if it were possible to call a child's function inside the parent?
For example, can I use useRef to create a reference to the child and then call the function like that? Or is there ...
4
votes
1
answer
24k
views
Export function inside functional component in react
It is possible to export a function that is inside a functional component and that can be imported into another?
Example code: https://codesandbox.io/s/blissful-sanne-chk5g?file=/src/App.js:0-275
...
7
votes
4
answers
16k
views
how to call function of child in functional component from parent in react.js?
I have two components:
parent
child
The parent is class component and child is functional component. What is best practice to call child methods from the parent component?
The goal of these ...
7
votes
1
answer
13k
views
Use useRef to call submitForm from a parent component
I am using react hooks and useRef to call a child method from the parent (see here: Call child method from parent)
Specifically, I am trying to call the formik submitForm method which is located in ...
2
votes
3
answers
8k
views
Call child component method from parent in react
I have simple component called List which is a simple ul with some li inside. Each li is a simple component.
I have other parent component which render one input field and the List component. Tapping ...