Click here to Skip to main content
15,798,826 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to create a react app that has a NavBar component, contains a few links, and a Login component, which has two input elements and a button. When a user types in the inputs, their contents should be stored in state. When the user clicks the button, the page should show 'true' if both inputs are longer than 2 characters, and otherwise, it should show 'false'.

How do I write this to make record the information in State?

What I have tried:

class Counter extends React.Component {
  state = {
    current: 0

  constructor() {
    this.intervalId = null;

  updateCounter() {
    this.setState({ counter: this.state.current + 1 });

  componentWillMount() {
    this.setState({ counter: this.props.from || 0 });
    this.intervalId = setInterval(this.updateCounter.bind(this), 1000);

  componentWillUnmount() {

  render() {
    return <span>{ this.state.current }</span>;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900