ReactJS Render Component

Karthikeyan

I'm new to ReactJS. I should want to re-render a component from some other component. For Example, I have inserted and show component. I want to re-render show component after click submits button of insert component.

Show Component :

import React from 'react';         
import Fetch from 'react-fetch';
import styler from 'react-styling'

class Show extends React.Component {              
  render() {
    return (  
      <div>   
       <h1>Show Component </h1>
      </div>                 
    );
  }
}    
export default Show;

Insert Component :

import React from 'react';         
import Fetch from 'react-fetch';
import styler from 'react-styling'

class Insert extends React.Component {    
  handleSubmit(event) {
             //Some code
    }   
  render() {
    return (
    <form onSubmit={this.handleSubmit}>

     <label >name</label>
     <input type="text" name="name" value={this.state.name} onChange=     
     {this.handleInputChange}  />    
    <input type="submit" value="Submit"   />     
  </form>    
 );
  }
}    
export default Show;

Now I want to call or re-render or refresh show component whenever I click submit button from Insert component. Thanks in advance.

Pranay Tripathi

You must have the Insert Component as the react child of the Show component in order to communicate in between two components. The component render can be performed by the changing of state for parent component and changing of props for the child component. In your case none of the conditions are being satisfied. You can also achieve this via flux framework where you can add listener to a Flux Store and add eventListener on your component to re-render with changes in the Store.

Before going to all of this I would suggest that you go through the React concepts more throughly in order to understand state and props behaviours in between components.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Render reactjs component not work

From Dev

Render variable component name in reactjs

From Dev

reactjs - How to render a component which render return a component?

From Dev

Render Inner Component in a Custom DOM Node in Reactjs

From Dev

Reactjs Render component dynamically based on a JSON config

From Dev

Reactjs How to insert react component into string and then render

From Dev

Reactjs How to insert react component into string and then render

From Dev

ReactJS - Render top level component on load

From Dev

How to render the leaf component of tree component without re-render entire tree in ReactJS

From Dev

ReactJS how to memoize within a loop to render the same component

From Dev

ReactJS - Passing prop value to component before final ReactDOM.render()

From Dev

If I enter URL manually or refresh the page the component will not render reactjs

From Dev

ReactJS how to memoize within a loop to render the same component

From Dev

reactjs - changing state doesn't re-render component

From Dev

Conditionally render content from API response in Reactjs component

From Dev

ReactJS - How do I render out a component from several prop arrays?

From Dev

ReactJS) how to get data with XMLHttpRequest from PHP and render that data inside sibling component

From Dev

reactjs render rows dynamically

From Dev

How to render accents in ReactJs?

From Dev

Render function in reactjs

From Dev

ReactJS componentDidMount + render

From Dev

Non blocking render in ReactJS

From Dev

ReactJS render elements with js

From Dev

reactjs render rows dynamically

From Dev

ReactJs if else in render

From Dev

How to render a string in reactjs

From Dev

Map and Render a Subarray in ReactJS

From Dev

Render object in reactjs

From Dev

How to render a Component if the prop is a component?

Related Related

  1. 1

    Render reactjs component not work

  2. 2

    Render variable component name in reactjs

  3. 3

    reactjs - How to render a component which render return a component?

  4. 4

    Render Inner Component in a Custom DOM Node in Reactjs

  5. 5

    Reactjs Render component dynamically based on a JSON config

  6. 6

    Reactjs How to insert react component into string and then render

  7. 7

    Reactjs How to insert react component into string and then render

  8. 8

    ReactJS - Render top level component on load

  9. 9

    How to render the leaf component of tree component without re-render entire tree in ReactJS

  10. 10

    ReactJS how to memoize within a loop to render the same component

  11. 11

    ReactJS - Passing prop value to component before final ReactDOM.render()

  12. 12

    If I enter URL manually or refresh the page the component will not render reactjs

  13. 13

    ReactJS how to memoize within a loop to render the same component

  14. 14

    reactjs - changing state doesn't re-render component

  15. 15

    Conditionally render content from API response in Reactjs component

  16. 16

    ReactJS - How do I render out a component from several prop arrays?

  17. 17

    ReactJS) how to get data with XMLHttpRequest from PHP and render that data inside sibling component

  18. 18

    reactjs render rows dynamically

  19. 19

    How to render accents in ReactJs?

  20. 20

    Render function in reactjs

  21. 21

    ReactJS componentDidMount + render

  22. 22

    Non blocking render in ReactJS

  23. 23

    ReactJS render elements with js

  24. 24

    reactjs render rows dynamically

  25. 25

    ReactJs if else in render

  26. 26

    How to render a string in reactjs

  27. 27

    Map and Render a Subarray in ReactJS

  28. 28

    Render object in reactjs

  29. 29

    How to render a Component if the prop is a component?

HotTag

Archive