OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

how to navigate from one page to another in react js?

  • Thread starter Thread starter user5711656
  • Start date Start date
U

user5711656

Guest
I have two components. In first component I have one button. On click of button I want to navigate to another component or another page.

here is my code http://codepen.io/naveennsit/pen/pymqPa?editors=1010

Code:
class App extends React.Component {
    handleClick(){
      alert('---');
    }

    render() {
        return <button onClick={this.handleClick}>hello</button>
    }
}

class Second extends React.Component {
    render() {
        return <label>second component</label>
    }
}

React.render( <App /> , document.getElementById('app'))

<p>I have two components. In first component I have one button. On click of button I want to navigate to another component or another page.</p>

<p>here is my code
<a href="http://codepen.io/naveennsit/pen/pymqPa?editors=1010" rel="noreferrer">http://codepen.io/naveennsit/pen/pymqPa?editors=1010</a></p>

<pre><code>class App extends React.Component {
handleClick(){
alert('---');
}

render() {
return <button onClick={this.handleClick}>hello</button>
}
}

class Second extends React.Component {
render() {
return <label>second component</label>
}
}

React.render( <App /> , document.getElementById('app'))
</code></pre>
 

Latest posts

Online statistics

Members online
0
Guests online
2
Total visitors
2
Ads by Eonads
Top