Migrating from Javascript to ReactJS

Migrating from Javascript to ReactJS
0

#1

Hi! I’ve started making my first app in Electron and many people suggested to try React, Angular or Vue. So I picked React and I’m trying to rewrite my app. (github/ttomovcik/gakko)

I had one main UI and Settings. Now, to be clear - I’m complete beginner, I’ve been doing some stuff in Java only before.

Here’s the problem. Basically, I have no idea how to add the following things:

  • Variable (var something = “somethnig1”)
  • Add function to component (I’ve had this in JS:)
 /**
   * Gets current date and time and returns it's values as array
   * @type {Array}
   */
  getCurrentDateTime() {
    var date = new Date();
    var day = date.getDate();
    var month = (date.getMonth() + 1);
    var year = date.getFullYear();
    var hour = this.prettifyLTTValues(date.getHours());
    var minute = this.prettifyLTTValues(date.getMinutes());
    var second = this.prettifyLTTValues(date.getSeconds());
    //     [ 0  ,  1  ,   2  ,  3 ,   4   ,   5   ]
    return [day, month, year, hour, minute, second];
  };

  /**
   * Checks if the input is < 10 and returns value with 0 before input value
   *  @param {(string|number)} i
   */
  prettifyLTTValues(i) {
    if (i < 10) {
        i = "0" + i
    };
    return i
  };
  • and call the functions
    • And update variable (var something = getCurrentDateTime())

Tried reading docs but I still have no idea where to start or what to learn first.

I’d be thankful for any suggestions or ideas!


#2

doing the react tutorial might help


#3

Wow. I went staright to the docs and skipped / overlooked the tutorial. Thanks!