Skip to content

Instantly share code, notes, and snippets.

View Designer023's full-sized avatar

Carl Topham Designer023

View GitHub Profile
@Designer023
Designer023 / ListItem.js
Created April 17, 2017 15:04
List item export
export default ListItem;
@Designer023
Designer023 / List.js
Created April 17, 2017 15:03
List JS Export
export default List;
@Designer023
Designer023 / List.js
Created April 17, 2017 15:01
List JS Imports
import React, { Component } from 'react';
import ListItem from './ListItem';
...
@Designer023
Designer023 / App.js
Created April 17, 2017 15:00
App js imports
import React, { Component } from 'react';
import List from './components/List';
...
@Designer023
Designer023 / ListItem.js
Created April 17, 2017 14:59
ListItem JS initial
import React, { Component } from 'react';
class ListItem extends Component {
render() {
return (
<li>{this.props.text}</li>
)
}
}
@Designer023
Designer023 / List.js
Created April 17, 2017 14:58
List JS initial
import React, { Component } from 'react';
class List extends Component {
render() {
// Create variable with mapped data
let list_items = this.props.data.map(function(item, index) {
return (
<ListItem text={item} key={index} />
)
@Designer023
Designer023 / App.js
Created April 17, 2017 14:57
App JS Map prop data
// Create variable with mapped data
let list_items = this.props.data.map(function(item, index) {
return (
<ListItem text={item} key={index} />
)
})
@Designer023
Designer023 / App.js
Created April 17, 2017 14:56
App JS Pass lists to Lists
class App extends Component {
render() {
return (
<div>
<h1>List of lists</h1>
<h2>Top animals</h2>
<List data={top_animals} />
<h2>Other animals</h2>
<List data={other_animals} />
</div>
@Designer023
Designer023 / App.js
Created April 17, 2017 14:53
App JS More data
let top_animals = [
"Cat",
"Dog",
"Fish",
"Parrot",
"Rabbit"
]
let other_animals = [
"koala",
@Designer023
Designer023 / App.js
Created April 17, 2017 14:52
App JS Second List
class App extends Component {
render() {
return (
<div>
<h1>List of lists</h1>
<h2>Top animals</h2>
<List />
<h2>Other animals</h2>
<List />
</div>