Skip to content

Instantly share code, notes, and snippets.

@tadjohnston
Last active June 10, 2020 17:24
Show Gist options
  • Select an option

  • Save tadjohnston/15d42e8bb7eaa8277444adef51f0576b to your computer and use it in GitHub Desktop.

Select an option

Save tadjohnston/15d42e8bb7eaa8277444adef51f0576b to your computer and use it in GitHub Desktop.

Revisions

  1. tadjohnston revised this gist Oct 9, 2019. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions Foo.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ class Foo extends Component {
    list: '',
    }

    items(list) {
    items = (list) => {
    const filteredList = list
    .filter(i => i !== null)
    .map(item => ({ bar: item.baz }))
    @@ -41,6 +41,4 @@ class Foo extends Component {
    </div>
    )
    }
    }

    export default Foo
    }
  2. tadjohnston revised this gist Jun 21, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions Foo.js
    Original file line number Diff line number Diff line change
    @@ -12,9 +12,9 @@ class Foo extends Component {
    }

    items(list) {
    const filteredList = list.map(item => ({
    bar: item.baz,
    })).filter(i => i !== null)
    const filteredList = list
    .filter(i => i !== null)
    .map(item => ({ bar: item.baz }))

    return filteredList.map((item, index) => (
    <Baz
  3. tadjohnston revised this gist Jun 21, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Foo.js
    Original file line number Diff line number Diff line change
    @@ -32,11 +32,11 @@ class Foo extends Component {
    <div>
    {list && (
    <div>
    {`Count is: ${this.props.count} for items: `} {this.items(list)}
    {`Count is ${this.props.count} for items: `} {this.items(list)}
    </div>
    )}
    {!list && (
    {`Count is: ${this.props.count} for items: `} n/a
    {`Count is ${this.props.count} for items: `} n/a
    )}
    </div>
    )
  4. tadjohnston revised this gist Jun 21, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions Foo.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    import React, { PureComponent, Fragment } from 'react'
    import React, { Component } from 'react'
    import PropTypes from 'prop-types'
    import Baz from 'baz'

    class Foo extends PureComponent {
    class Foo extends Component {
    static propTypes = {
    list: PropTypes.array,
    }
    @@ -31,9 +31,9 @@ class Foo extends PureComponent {
    return (
    <div>
    {list && (
    <Fragment>
    <div>
    {`Count is: ${this.props.count} for items: `} {this.items(list)}
    </Fragment>
    </div>
    )}
    {!list && (
    {`Count is: ${this.props.count} for items: `} n/a
  5. tadjohnston revised this gist Jun 21, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Foo.js
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ class Foo extends PureComponent {
    <Baz
    key={index}
    bar={item.bar}
    bar={item.something}
    something={item.bar}
    />
    ))
    }
  6. tadjohnston revised this gist Jun 21, 2019. 1 changed file with 10 additions and 3 deletions.
    13 changes: 10 additions & 3 deletions Foo.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    import React from 'react'
    import React, { PureComponent, Fragment } from 'react'
    import PropTypes from 'prop-types'
    import Baz from 'baz'

    class Foo extends React.PureComponent {
    class Foo extends PureComponent {
    static propTypes = {
    list: PropTypes.array,
    }
    @@ -30,7 +30,14 @@ class Foo extends React.PureComponent {

    return (
    <div>
    {`Count is: ${this.props.count} for items: `} {this.items(list)}
    {list && (
    <Fragment>
    {`Count is: ${this.props.count} for items: `} {this.items(list)}
    </Fragment>
    )}
    {!list && (
    {`Count is: ${this.props.count} for items: `} n/a
    )}
    </div>
    )
    }
  7. tadjohnston revised this gist Jun 21, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Foo.js
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,8 @@ class Foo extends React.PureComponent {
    return filteredList.map((item, index) => (
    <Baz
    key={index}
    bar={item.bar}
    bar={item.bar}
    bar={item.something}
    />
    ))
    }
  8. tadjohnston renamed this gist Jun 21, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. tadjohnston created this gist Jun 21, 2019.
    38 changes: 38 additions & 0 deletions Foo.js Review
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    import React from 'react'
    import PropTypes from 'prop-types'
    import Baz from 'baz'

    class Foo extends React.PureComponent {
    static propTypes = {
    list: PropTypes.array,
    }

    static defaultProps = {
    list: '',
    }

    items(list) {
    const filteredList = list.map(item => ({
    bar: item.baz,
    })).filter(i => i !== null)

    return filteredList.map((item, index) => (
    <Baz
    key={index}
    bar={item.bar}
    />
    ))
    }

    render() {
    const { list } = this.props

    return (
    <div>
    {`Count is: ${this.props.count} for items: `} {this.items(list)}
    </div>
    )
    }
    }

    export default Foo