Skip to content

Instantly share code, notes, and snippets.

View purushotamrai's full-sized avatar
👨‍💻
git bisect good

Purushotam Rai purushotamrai

👨‍💻
git bisect good
View GitHub Profile
@purushotamrai
purushotamrai / DestinationList.js
Created February 14, 2019 17:11
Getting Started with ReactJS and Drupal - Step 4.2 - DestinationList.js
import React from 'react';
import DestinationItem from "./DestinationItem";
export default class DestinationList extends React.Component {
render() {
let { data } = this.props;
return (
<div>
<h1>Here are your best Travel Destinations</h1>
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:08
Getting Started with ReactJS and Drupal - Step 4.1 - App.js - render
render() {
return (
<div className="App">
<DestinationList
data={this.state.data}
/>
</div>
);
}
@purushotamrai
purushotamrai / App.js
Last active February 14, 2019 17:09
Getting Started with ReactJS and Drupal - Step 4.1 - App.js - componentWillMount
componentWillMount() {
  this.loadDestinations();
 }
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:07
Getting Started with ReactJS and Drupal - Step 4.1 - App.js updateData
updateData(responseData) {
  this.setState({data: responseData.data});
 }
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:06
Getting Started with ReactJS and Drupal - Step 4.1 - App.js - loadDestinations
loadDestinations() {
// Fetch Destinations.
fetch(LIST_URL, {mode:'cors'})
.then(function (response) {
return response.json();
})
.then((data) => this.updateData(data))
.catch(err => console.log('Fetching Destinations Failed', err));
}
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:05
Getting Started with ReactJS and Drupal - Step 4.1 - App.js
const LIST_URL = 'http://td-drupal.local:80/jsonapi/node/destination';
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:04
Getting Started with ReactJS and Drupal - Step 4.1 - App.js
constructor() {
super();
this.state = { data: null };
this.loadDestinations = this.loadDestinations.bind(this);
this.updateData = this.updateData.bind(this);
}
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:03
Getting Started with ReactJS and Drupal - Step 3 - App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import DestinationList from "./Components/Destination/DestinationList";
class App extends Component {
render() {
return (
<div className="App">
<DestinationList/>
@purushotamrai
purushotamrai / DestinationList.js
Created February 14, 2019 17:02
Getting Started with ReactJS and Drupal - Step 3 - DestinationList.js
import React from 'react';
import DestinationItem from "./DestinationItem";
export default class DestinationList extends React.Component {
render() {
return (
<div>
<h1>Here are your best Travel Destinations</h1>
<DestinationItem/>
@purushotamrai
purushotamrai / DestinationItem.js
Created February 14, 2019 17:00
Getting Started with ReactJS and Drupal - Step 3 - DestinationItem.js
import React from 'react';
export default class DestinationItem extends React.Component {
render() {
return (
<div>
<h2>Travel Destination Title</h2>
<div>Travel Destination Description goes here</div>