By good_evening


2019-07-11 19:00:08 8 Comments

The usual solution to updating parent is to pass the method from parent to the child, and then from child use props.method. However, parent class becomes too huge in my case, so I was wondering are there any disadvantages doing this:

<input value={message.sometext}
       onChange={(e) => {
         message.sometext = e.target.value;
         self.props.forceUpdate();
       }}/>

?

By using this, I can move logic to the child and have skinnier parent. Or forceupdating the whole state is a bad idea? Why, or why not? I am new to React, so sorry for a potentially dumb question. Thanks a lot.

0 comments

Related Questions

Sponsored Content

12 Answered Questions

[SOLVED] How to update parent's state in React?

2 Answered Questions

Child component does not update when parent state changes

0 Answered Questions

2 Answered Questions

[SOLVED] Passing store state as props, or each component accessing global stores?

2 Answered Questions

React - set state on unmounted component

1 Answered Questions

[SOLVED] How to call setState method of a parent component after updating child component's state?

  • 2018-08-10 11:08:45
  • ghazanfar malik
  • 166 View
  • 0 Score
  • 1 Answer
  • Tags:   reactjs

2 Answered Questions

[SOLVED] Performance on PureComponent vs stateless functional component

1 Answered Questions

1 Answered Questions

[SOLVED] What is the proper way to handle React state and props

  • 2016-04-01 18:34:44
  • André Moretzsohn de Castro
  • 184 View
  • 0 Score
  • 1 Answer
  • Tags:   reactjs render

Sponsored Content