Getting started with React is simple. There's only three things you need to know to get started: Components, props, and state.
Components are the basic building blocks of a react app. They have a render
method:
const React = require("react")
//old school es5 syntax for creating a class | |
//advantage: lets you create private functions and state through closure | |
//disadvantage: looks weird if you learned OO through language like c++/java/ruby, etc. Doesn't support prototypical inheritance. | |
//constructor function | |
function MyES5Class(aPrivateVar){ | |
var aontherPrivateVar = "I'm a private variable! You can't access me from the outside." | |
this.publicVar = "I'm a public variable! You can access me from the outside!" | |
this.myPublicFunction = function(){ |
function RPS(){ | |
this.play = function(p1, p2, ui){ | |
new PlayUseCase(p1, p2, ui).execute() | |
} | |
} | |
function PlayUseCase(p1, p2, ui){ | |
this.execute = function(){ | |
if (inputInvalid()){ | |
ui.invalid() |
Scenario: Valid tweet | |
Given there is a user "bob" with password "password" | |
And there is a user "alice" with password "password" | |
And I visit "/" | |
And I fill in "username" with "bob" | |
And I fill in "password" with "password" | |
And I click "Log in" | |
When I fill in "Tweet" with "this is a test tweet noise noise noise noise noise noise noise noise noise noise noise noise noise noise noise noise haha I'm less than 140 characters." | |
And I click "Submit" | |
Then I should see "Your tweet was submitted" |
# | |
# Feature: Test How Spinach Works | |
# | |
# Scenario: Test triple equals | |
# Given I have an empty array: | |
# """ | |
# @array = [] | |
# """ | |
# | |
# Then it should be empty: |
ruby-1.8.7-p334 :001 > require 'yaml' | |
=> true | |
ruby-1.8.7-p334 :002 > YAML.load File.read(".travis.yml") | |
=> {"before_script"=>"echo 'before start' && sed -i '' -e 's/admin:password\\@//' features/support/env.rb && echo 'before end'", "rvm"=>["1.8.7", "1.9.2", "1.9.3", "rbx-2.0", "ree"]} |
get "/", {}, "HTTP_HOST" => "example.org:9000" | |
last_request.port.should == 9000 | |
get "/", {}, "SERVER_PORT" => "9000" | |
last_request.port.should == 9000 | |
header "Host", "example.org:9000" | |
get "/" | |
last_request.port.should == 9000 |
-bash: /Users/mparker/.rvm/scripts/selector: line 202: syntax error near unexpected token `(' | |
-bash: /Users/mparker/.rvm/scripts/selector: line 202: ` if [[ -z "${rvm_ruby_version:-""}" ]] (( rvm_head_flag == 0 ))' | |
-bash: /Users/mparker/.rvm/scripts/selector: line 202: syntax error near unexpected token `(' | |
-bash: /Users/mparker/.rvm/scripts/selector: line 202: ` if [[ -z "${rvm_ruby_version:-""}" ]] (( rvm_head_flag == 0 ))' |
def my_reverse( a ) | |
reversed = [] | |
length_a = a.length | |
for counter in Array.new( length_a ) | |
last = a.pop | |
reversed.push( last ) | |
end | |
reversed | |
end |