Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8dfcc1

Browse files
authored
chore: Update using-javascript-transforms example to es6 declarations (gatsbyjs#21125)
* changed deprecated method componentWillReceiveProps to getDerivedStateFromProps, checked for props changes to trigger updates * Removed unnecessary component state, used props instead * changed vars to es6 keywords * undid changes * updated to ES6 * updated to ES6 * changed more files
1 parent aafbebe commit d8dfcc1

File tree

2 files changed

+6
-6
lines changed
  • examples/using-javascript-transforms/src/articles/2017-05-30-choropleth-on-d3v4-alternate
  • packages/gatsby-transformer-sharp/src

2 files changed

+6
-6
lines changed

examples/using-javascript-transforms/src/articles/2017-05-30-choropleth-on-d3v4-alternate/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react"
22
import { graphql } from "gatsby"
33
import BlogPostChrome from "../../components/BlogPostChrome"
4-
var d3 = require(`d3`)
4+
const d3 = require(`d3`)
55

66
// this is an additional method to export data and make it usable elsewhere
77
export const frontmatter = {
@@ -70,10 +70,10 @@ class choroplethAltBase extends React.Component {
7070

7171
export default choroplethAltBase
7272

73-
var graph = {} // we namespace our d3 graph into setup and draw
73+
let graph = {} // we namespace our d3 graph into setup and draw
7474

75-
var stateDataURL = `https://gist.githubusercontent.com/jbolda/52cd5926e9241d26489ec82fa2bddf37/raw/f409b82e51072ea23746325eff7aa85b7ef4ebbd/states.json`
76-
var statisticsDataURL = `https://gist.githubusercontent.com/jbolda/52cd5926e9241d26489ec82fa2bddf37/raw/f409b82e51072ea23746325eff7aa85b7ef4ebbd/stats.csv`
75+
const stateDataURL = `https://gist.githubusercontent.com/jbolda/52cd5926e9241d26489ec82fa2bddf37/raw/f409b82e51072ea23746325eff7aa85b7ef4ebbd/states.json`
76+
const statisticsDataURL = `https://gist.githubusercontent.com/jbolda/52cd5926e9241d26489ec82fa2bddf37/raw/f409b82e51072ea23746325eff7aa85b7ef4ebbd/stats.csv`
7777

7878
graph.setup = (selection, measurements) => {
7979
// the path string is drawn expecting:

packages/gatsby-transformer-sharp/src/customize-schema.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const {
3434
} = require(`./types`)
3535

3636
function toArray(buf) {
37-
var arr = new Array(buf.length)
37+
const arr = new Array(buf.length)
3838

39-
for (var i = 0; i < buf.length; i++) {
39+
for (let i = 0; i < buf.length; i++) {
4040
arr[i] = buf[i]
4141
}
4242

0 commit comments

Comments
 (0)