Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project React Data & Styling #13

Open
haydanu opened this issue Nov 15, 2019 · 14 comments
Open

Project React Data & Styling #13

haydanu opened this issue Nov 15, 2019 · 14 comments

Comments

@haydanu
Copy link
Member

haydanu commented Nov 15, 2019

@sharfinaega @Taufik66645 @Zakintaliban

@haydanu
Copy link
Member Author

haydanu commented Nov 15, 2019

import React, { Component } from 'react';

class StateClass extends Component {
  constructor(props) {
    super(props);

    this.state = {
      isLoading: true,
      classMate: ['Auzan', 'Iqbal', 'Zakin'],
      classMateName: ''
    };

    // this.changeLoadingState = this.changeLoadingState.bind(this);
  }

  changeLoadingState = () => {
    this.setState({
      isLoading: !this.state.isLoading
    });
  };

  getElementName = (index, data) => {
    console.log(`[${index}] ${data}`);
    this.setState({
      classMateName: data
    });
  };

  render() {
    if (!this.state.isLoading) {
      return <div onClick={this.changeLoadingState}>Ups</div>;
    } else {
      return (
        <div id='fragment'>
          <div onClick={this.changeLoadingState}>
            {this.state.isLoading ? 'Ini true' : 'Ini false'}
          </div>

          <div>
            <h1>Ini data data dari state array</h1>
            <ul>
              {this.state.classMate &&
                this.state.classMate.map((data, index) => {
                  return (
                    <li
                      key={index}
                      onClick={() => this.getElementName(index, data)}>
                      {data}
                    </li>
                  );
                })}
            </ul>
          </div>

          <div>
            <h1>Ini nama temen saya</h1>
            {this.state.classMateName && <p>{this.state.classMateName}</p>}
          </div>
        </div>
      );
    }
  }
}

export default StateClass;

@fariisiibrahiim
Copy link
Member

Baim learns ReactJS

@lighteagle
Copy link
Member

Project React Data

@iqbalelyas
Copy link
Member

React Data

@alhajiry
Copy link
Member

alhajiry commented Nov 15, 2019

@imanardiansyahh
Copy link
Member

React data

@dannyGan
Copy link
Member

counter project

@robyafrizal
Copy link
Member

robyafrizal commented Nov 15, 2019

Project React Counter

@sharfinaega
Copy link
Member

@monogamus
Copy link

Project React Counter

@Dianpuspitasari86
Copy link
Member

Project React Counter

@Taufik66645
Copy link
Member

Taufik66645 commented Nov 15, 2019

@iqbalmmm
Copy link
Member

iqbalmmm commented Nov 15, 2019

Project React Counter

@Zakintaliban
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment