Compare commits
1335 Commits
v0.4.1
...
0.9-stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1f66edf4e | ||
|
|
1133a938e9 | ||
|
|
bfd2921735 | ||
|
|
f2ca8943f5 | ||
|
|
aa655f6121 | ||
|
|
de4f3258fc | ||
|
|
08a7103535 | ||
|
|
79cd7ad57c | ||
|
|
c621c48be7 | ||
|
|
1d000bc4ce | ||
|
|
3d4cdc36a9 | ||
|
|
78cc5600fb | ||
|
|
b9ca151242 | ||
|
|
0a1fb12567 | ||
|
|
66cbb69383 | ||
|
|
17e6ffcb79 | ||
|
|
23a1d7d765 | ||
|
|
ca565f5b6c | ||
|
|
415c4621b7 | ||
|
|
0595a17c71 | ||
|
|
edd54f5149 | ||
|
|
4746669afb | ||
|
|
8dc1cdbd82 | ||
|
|
cd2aa12513 | ||
|
|
394173138e | ||
|
|
c98529ed90 | ||
|
|
274aca3093 | ||
|
|
c60a83758b | ||
|
|
26cd595a98 | ||
|
|
8840ee32f1 | ||
|
|
bb729a5784 | ||
|
|
b99705f690 | ||
|
|
7e7aa21e24 | ||
|
|
01b68c0e76 | ||
|
|
e59daa8ed8 | ||
|
|
9b405fba24 | ||
|
|
99b80938af | ||
|
|
e13977c0c2 | ||
|
|
42473b2df1 | ||
|
|
970ae44c1f | ||
|
|
a447d30a2e | ||
|
|
36e97bac21 | ||
|
|
9f9ee697f3 | ||
|
|
58ffd39abf | ||
|
|
30faba394d | ||
|
|
93e7778d5f | ||
|
|
b7836c4da6 | ||
|
|
c2904b978e | ||
|
|
8122cadeb4 | ||
|
|
ea803c47ba | ||
|
|
42c837e4dd | ||
|
|
cadd6cbb6c | ||
|
|
c0660ea6e0 | ||
|
|
cb1f8247e5 | ||
|
|
e0dbca1168 | ||
|
|
f81d16960c | ||
|
|
8a47813baa | ||
|
|
792d8aca86 | ||
|
|
112a20ce73 | ||
|
|
c79974db3a | ||
|
|
5795376961 | ||
|
|
8ac5975ad8 | ||
|
|
d8fd1af4a0 | ||
|
|
f457df275d | ||
|
|
39c9b539e9 | ||
|
|
ae7e44ec84 | ||
|
|
f73b894c37 | ||
|
|
4642a70277 | ||
|
|
2f0bb69708 | ||
|
|
916776753f | ||
|
|
1b5af6b405 | ||
|
|
9e160df868 | ||
|
|
9125f68194 | ||
|
|
9ebb40f013 | ||
|
|
7b5da078c6 | ||
|
|
1167aeb453 | ||
|
|
6780b47526 | ||
|
|
3e77f64141 | ||
|
|
827c44fcd3 | ||
|
|
b7ba0f173e | ||
|
|
634e41788a | ||
|
|
47ae865428 | ||
|
|
0d4213001b | ||
|
|
1e7bdc79e1 | ||
|
|
e87c8a2aa4 | ||
|
|
d3c12487fd | ||
|
|
32e1d76612 | ||
|
|
78ac842b4a | ||
|
|
9ebde97c14 | ||
|
|
2013db23d3 | ||
|
|
e872cd0a7c | ||
|
|
a34eed508a | ||
|
|
adcbf0806c | ||
|
|
64afa545dd | ||
|
|
f66f8f0310 | ||
|
|
9ba014fbf1 | ||
|
|
d71736b3ed | ||
|
|
529c971db3 | ||
|
|
b65f5a4d30 | ||
|
|
123ed1f442 | ||
|
|
31bc18d39e | ||
|
|
f4798ebee1 | ||
|
|
67c5d76321 | ||
|
|
a8af11b46d | ||
|
|
30646c9c1e | ||
|
|
8c3ac3203d | ||
|
|
559933655a | ||
|
|
0a9eaab61f | ||
|
|
cebc49e5e6 | ||
|
|
f8349f9614 | ||
|
|
80cbdea144 | ||
|
|
1991e46f1a | ||
|
|
b98f1adf1a | ||
|
|
05ee61d763 | ||
|
|
cc010e3287 | ||
|
|
49ddf905b1 | ||
|
|
ecfd0c1473 | ||
|
|
4a76b52751 | ||
|
|
940c86964d | ||
|
|
ac1c90e864 | ||
|
|
47645854f9 | ||
|
|
acbba1ae67 | ||
|
|
5c953a7bdd | ||
|
|
d1a337b9db | ||
|
|
1012b2ff4b | ||
|
|
6573a726ba | ||
|
|
a5c518f69a | ||
|
|
f02c3c07d3 | ||
|
|
b04df6335a | ||
|
|
fff48c5921 | ||
|
|
cda1d8c779 | ||
|
|
6f305505a7 | ||
|
|
cd87848b7d | ||
|
|
55be7a71c5 | ||
|
|
f37474b75b | ||
|
|
b0757c5182 | ||
|
|
d0502cf3c1 | ||
|
|
3895353326 | ||
|
|
5abcce5343 | ||
|
|
75b58d2ad2 | ||
|
|
94ef6c51fb | ||
|
|
439bca78ed | ||
|
|
9ac27cb551 | ||
|
|
a6749a686f | ||
|
|
12ebf33f89 | ||
|
|
d547374847 | ||
|
|
756bd975b1 | ||
|
|
da587b15d5 | ||
|
|
db6ff14e7d | ||
|
|
8f298fbd69 | ||
|
|
49747347fb | ||
|
|
35d9286781 | ||
|
|
8cf5882447 | ||
|
|
3f243bc4f9 | ||
|
|
fc2805fe03 | ||
|
|
89bcecc76f | ||
|
|
0f4cc6ee84 | ||
|
|
25e56a4540 | ||
|
|
66b290c32f | ||
|
|
6e5956195d | ||
|
|
c544b01cad | ||
|
|
5f1d4d7c14 | ||
|
|
c1c2dd9a89 | ||
|
|
acfef143ae | ||
|
|
30fd3a30b0 | ||
|
|
2e17144ac0 | ||
|
|
40547125f8 | ||
|
|
eb3d516f40 | ||
|
|
1194a040f9 | ||
|
|
42e65ddb3e | ||
|
|
141f3a8ac8 | ||
|
|
d00b11ef03 | ||
|
|
463f940c7f | ||
|
|
26fb009e0c | ||
|
|
9ae002503c | ||
|
|
b199de29a0 | ||
|
|
bc27325d31 | ||
|
|
d8700f04da | ||
|
|
721ac85bf8 | ||
|
|
3141bc5084 | ||
|
|
bc1e950a41 | ||
|
|
e9e44773ee | ||
|
|
94d11ecf05 | ||
|
|
71c10b9f45 | ||
|
|
5f941628e0 | ||
|
|
497dab2ad9 | ||
|
|
4c1a737343 | ||
|
|
73b4f954f2 | ||
|
|
4ebdb2c0ac | ||
|
|
e0262d50f9 | ||
|
|
647e65525c | ||
|
|
8360da2937 | ||
|
|
2f812b6f9b | ||
|
|
c7dd8d4217 | ||
|
|
9c5c1ed902 | ||
|
|
7ad28183b4 | ||
|
|
2031946946 | ||
|
|
b9cd2f0d3d | ||
|
|
2435b66840 | ||
|
|
a528beeda9 | ||
|
|
1a39c3143c | ||
|
|
a21979404c | ||
|
|
9730759322 | ||
|
|
945f788a41 | ||
|
|
8d1d29286a | ||
|
|
17f602f924 | ||
|
|
7aaa3a4ed1 | ||
|
|
3642b6ea62 | ||
|
|
bced44533f | ||
|
|
f9bb6e46f1 | ||
|
|
e14555caed | ||
|
|
aebfd641aa | ||
|
|
9e1c6950b1 | ||
|
|
220687abda | ||
|
|
0dc0b45f3c | ||
|
|
c8a2018228 | ||
|
|
19ff353fdd | ||
|
|
4992423547 | ||
|
|
6d4b470cfc | ||
|
|
9f1ed709d0 | ||
|
|
77c53dd5d4 | ||
|
|
e994e06c54 | ||
|
|
806e879566 | ||
|
|
fa046ca04e | ||
|
|
86373d924c | ||
|
|
5dabba999b | ||
|
|
57bf7d21f3 | ||
|
|
ce95c3d042 | ||
|
|
92fdc1562d | ||
|
|
4e9352f8f8 | ||
|
|
cd2aecc377 | ||
|
|
85270ae154 | ||
|
|
92a20220e7 | ||
|
|
e4d1618f63 | ||
|
|
78f3addd01 | ||
|
|
036303ee90 | ||
|
|
26c6ea961b | ||
|
|
aaada5e212 | ||
|
|
f18bda51d6 | ||
|
|
3119d66e26 | ||
|
|
98432365d9 | ||
|
|
a2e805b26e | ||
|
|
f7949c1c23 | ||
|
|
fce6d114fe | ||
|
|
f1b7db9aef | ||
|
|
f1b54bc310 | ||
|
|
e58064a8db | ||
|
|
bff9731b66 | ||
|
|
1666935878 | ||
|
|
43a242b67f | ||
|
|
5d7563f706 | ||
|
|
4cbc4b58f6 | ||
|
|
b225b34f91 | ||
|
|
32f69713fc | ||
|
|
cf1089fa0e | ||
|
|
00f2a053f0 | ||
|
|
65490a09e6 | ||
|
|
d8e9eb978b | ||
|
|
46c6ac5bb0 | ||
|
|
132e8b3c43 | ||
|
|
4894055114 | ||
|
|
b5dbbd5b2d | ||
|
|
470a7d11ee | ||
|
|
34e6a51e19 | ||
|
|
933681b42c | ||
|
|
0bca41fc93 | ||
|
|
864366d082 | ||
|
|
f368f18b61 | ||
|
|
36fd1def84 | ||
|
|
0e5dfd3fec | ||
|
|
d300df51e1 | ||
|
|
989eb2e7d9 | ||
|
|
526be1570e | ||
|
|
e3342f31b2 | ||
|
|
4aececb645 | ||
|
|
7614af3c9a | ||
|
|
4975113f20 | ||
|
|
ce92efefc0 | ||
|
|
4a5a6ad733 | ||
|
|
62b52e008e | ||
|
|
b1e6c4d0dd | ||
|
|
db04043eaa | ||
|
|
1e702f7258 | ||
|
|
97518fd664 | ||
|
|
38491c7c93 | ||
|
|
ad9c5e9242 | ||
|
|
91ef878ca8 | ||
|
|
2521b47707 | ||
|
|
79995a05c7 | ||
|
|
7b047111a0 | ||
|
|
b872100be6 | ||
|
|
14cb99c9aa | ||
|
|
c16b5659a0 | ||
|
|
0af9c3ebe7 | ||
|
|
95a80591dd | ||
|
|
f0b01d0faa | ||
|
|
1d1a790df0 | ||
|
|
ca02a068b8 | ||
|
|
8b12670ef9 | ||
|
|
2cac321b27 | ||
|
|
9c91546451 | ||
|
|
494f6e9c34 | ||
|
|
e3248efe92 | ||
|
|
559cd46181 | ||
|
|
e931dba107 | ||
|
|
de7a92afa7 | ||
|
|
d829d1ab9b | ||
|
|
b1a949ed45 | ||
|
|
4b392f19a8 | ||
|
|
ffc31ed77b | ||
|
|
df8d092609 | ||
|
|
ca930efa7c | ||
|
|
9558285f09 | ||
|
|
c5f0e14985 | ||
|
|
d8d4120614 | ||
|
|
ea711f1d62 | ||
|
|
4440486a24 | ||
|
|
0d2510ad9c | ||
|
|
79beb71d69 | ||
|
|
d489637a4f | ||
|
|
2ac36178c6 | ||
|
|
487f633643 | ||
|
|
8abca77381 | ||
|
|
71b585325c | ||
|
|
a05cef4a40 | ||
|
|
4f53f58754 | ||
|
|
ef4bda326e | ||
|
|
804280275b | ||
|
|
c2d57dff4b | ||
|
|
c72e906841 | ||
|
|
703a29c0b2 | ||
|
|
76a7e2de75 | ||
|
|
2562813c63 | ||
|
|
89819de4f2 | ||
|
|
b5f905523b | ||
|
|
4bdea53d6e | ||
|
|
9ade3c26d3 | ||
|
|
0906d282ec | ||
|
|
8ca62bd022 | ||
|
|
a69f98b834 | ||
|
|
e1f4357ff7 | ||
|
|
615dedc3e2 | ||
|
|
94727f8223 | ||
|
|
a821f03cf4 | ||
|
|
fd02f2c1cd | ||
|
|
c3a2ea2256 | ||
|
|
977b60c1ed | ||
|
|
091534c376 | ||
|
|
17de85689e | ||
|
|
b131da3869 | ||
|
|
d96c6914c7 | ||
|
|
f62ec225e0 | ||
|
|
9420e86480 | ||
|
|
c885abbf21 | ||
|
|
6c7697a1a9 | ||
|
|
eb2ac7f2f2 | ||
|
|
d9b959884b | ||
|
|
5857eb884c | ||
|
|
2f027fce2d | ||
|
|
ad70848e80 | ||
|
|
c6f91ee6e8 | ||
|
|
ca1ecc626b | ||
|
|
1825f30353 | ||
|
|
124096a9fe | ||
|
|
ad6a982cd0 | ||
|
|
3d47177596 | ||
|
|
ddcab8be99 | ||
|
|
425fd2ca08 | ||
|
|
59cba3e9f7 | ||
|
|
6ebb1cb3ee | ||
|
|
972acb4581 | ||
|
|
2c335b0e57 | ||
|
|
d14ce00dc3 | ||
|
|
d8a8f6a881 | ||
|
|
bcacd17f8b | ||
|
|
f71dbab31a | ||
|
|
73d9d286ee | ||
|
|
49d6d2169d | ||
|
|
1efb14bcf6 | ||
|
|
d6afb5285e | ||
|
|
979ee27e2b | ||
|
|
d73f80ecb2 | ||
|
|
423380f9c3 | ||
|
|
b70c3ef4bb | ||
|
|
ac0373ccae | ||
|
|
095eea3241 | ||
|
|
338ce603f9 | ||
|
|
95cb79a93e | ||
|
|
b713c2c696 | ||
|
|
f5a48f1ff4 | ||
|
|
f47238be41 | ||
|
|
851f08bdc2 | ||
|
|
68bac7fbf0 | ||
|
|
dea6063dc9 | ||
|
|
8dbc530d1c | ||
|
|
1f5c8d21d8 | ||
|
|
2c93cd0267 | ||
|
|
e3e3b477d3 | ||
|
|
4d3a9c87d1 | ||
|
|
87a95155be | ||
|
|
3c40fb2e01 | ||
|
|
2716f38861 | ||
|
|
e2f094614f | ||
|
|
09011493c5 | ||
|
|
0c3628cd8d | ||
|
|
1db788b62c | ||
|
|
2052caf0cc | ||
|
|
76a0a9cba7 | ||
|
|
46f7163f62 | ||
|
|
8d0885e0d8 | ||
|
|
b4f4f10478 | ||
|
|
23ab30ff87 | ||
|
|
b1597ab2d7 | ||
|
|
be42d94f12 | ||
|
|
33fe8eebda | ||
|
|
f0fdabae7b | ||
|
|
a2ecee5353 | ||
|
|
657602135c | ||
|
|
4f57515f91 | ||
|
|
59bd45d594 | ||
|
|
c28e1f24df | ||
|
|
ba6c82a326 | ||
|
|
e23c06a60c | ||
|
|
70a0746e9f | ||
|
|
1e980a146f | ||
|
|
57f208e402 | ||
|
|
f9551d709e | ||
|
|
c75899f277 | ||
|
|
09c8ec51bf | ||
|
|
6fdf36af13 | ||
|
|
5968571952 | ||
|
|
e9484adf65 | ||
|
|
fb858a8fc2 | ||
|
|
4f09a54a1d | ||
|
|
8f2509e169 | ||
|
|
79c9025f17 | ||
|
|
9454282bfc | ||
|
|
147506a911 | ||
|
|
b7b4bcfd2e | ||
|
|
808f60f8a0 | ||
|
|
bd575eb7c8 | ||
|
|
c2be8ba42d | ||
|
|
627d7eb669 | ||
|
|
182a237fa7 | ||
|
|
22ba8b67f1 | ||
|
|
e65726cd04 | ||
|
|
1584aaf746 | ||
|
|
089a494a1f | ||
|
|
9b3342ed34 | ||
|
|
7630e56971 | ||
|
|
9cce0c2752 | ||
|
|
91821007ed | ||
|
|
6dd62b0e4f | ||
|
|
42262f5361 | ||
|
|
2c1a25411f | ||
|
|
13230a3044 | ||
|
|
b366e36367 | ||
|
|
ed3d5add76 | ||
|
|
0e5b62a4c3 | ||
|
|
5b43a2e6d7 | ||
|
|
c01f0a0487 | ||
|
|
c4d918aca0 | ||
|
|
ae9188db50 | ||
|
|
202a3f184d | ||
|
|
605b42e622 | ||
|
|
ee0a4acfac | ||
|
|
e92d769a50 | ||
|
|
33dcf8a0b5 | ||
|
|
80d7d2d0f8 | ||
|
|
309a88bcf6 | ||
|
|
a575e93ecd | ||
|
|
ea40a6aedd | ||
|
|
047e962a55 | ||
|
|
fdfd7c1853 | ||
|
|
be75e3be66 | ||
|
|
c11d6d79f5 | ||
|
|
d270e2b1c7 | ||
|
|
e3e24500ae | ||
|
|
86f2dbe55d | ||
|
|
344b5998a8 | ||
|
|
4de2d39f63 | ||
|
|
7264cbcdfb | ||
|
|
1b67ac90f2 | ||
|
|
29190a2c79 | ||
|
|
bcfb476366 | ||
|
|
1ee7f8131c | ||
|
|
a00e4c840c | ||
|
|
cbefc5a968 | ||
|
|
f3e774559f | ||
|
|
1733d42ded | ||
|
|
cc005668b5 | ||
|
|
5661d5168e | ||
|
|
fb8277c819 | ||
|
|
5aae5a7b1d | ||
|
|
acf0c5c646 | ||
|
|
e915294b68 | ||
|
|
1755d43add | ||
|
|
04ad3bfcc3 | ||
|
|
a78f6f7f94 | ||
|
|
f0b5219df9 | ||
|
|
3396654a6f | ||
|
|
e244df510d | ||
|
|
7a9e5443b7 | ||
|
|
261926303d | ||
|
|
e91a8a1bc3 | ||
|
|
3defe88192 | ||
|
|
7675611e5f | ||
|
|
9a4f011f6c | ||
|
|
c877451887 | ||
|
|
96782fc836 | ||
|
|
1155aa9ac0 | ||
|
|
41526091a0 | ||
|
|
b2e51c6e01 | ||
|
|
a2e352ea76 | ||
|
|
55b7a57e07 | ||
|
|
1d4d1a0be6 | ||
|
|
7dca85a9b1 | ||
|
|
1c90172cd0 | ||
|
|
f871147b4d | ||
|
|
1671efb53a | ||
|
|
8915f1b85d | ||
|
|
92b440b1d7 | ||
|
|
3b0f705658 | ||
|
|
23eac0bbbb | ||
|
|
50d190f111 | ||
|
|
47fe931549 | ||
|
|
b3e1697aad | ||
|
|
4190d0a7bb | ||
|
|
40e2d8a064 | ||
|
|
e1ec9a6c65 | ||
|
|
e2ebbeac07 | ||
|
|
eab2ededdf | ||
|
|
7e29f4607b | ||
|
|
cce91611aa | ||
|
|
76c9d8465e | ||
|
|
abee8b0476 | ||
|
|
82c4e897dc | ||
|
|
17f14d523b | ||
|
|
f5f464b16a | ||
|
|
0647c2ee98 | ||
|
|
f03d6e212a | ||
|
|
918c5134e1 | ||
|
|
8f5ef0fdf2 | ||
|
|
84cacaf5b6 | ||
|
|
72fd24662e | ||
|
|
fdf64919f3 | ||
|
|
ff9ca2ecb2 | ||
|
|
f627bc52b0 | ||
|
|
9f10bb4aca | ||
|
|
a6b888b214 | ||
|
|
cbd6d8a46c | ||
|
|
01b4b23118 | ||
|
|
9e6456ba41 | ||
|
|
a4bb44f1e2 | ||
|
|
fac676073a | ||
|
|
5e6e332d67 | ||
|
|
77697f26e3 | ||
|
|
79b00591f1 | ||
|
|
556065937b | ||
|
|
411f0bd7c3 | ||
|
|
f877c6224f | ||
|
|
f9947dec2a | ||
|
|
e35f4c29bb | ||
|
|
ecf9f8ef6d | ||
|
|
2b0dc71e3d | ||
|
|
cc229eb749 | ||
|
|
633125fd0d | ||
|
|
30f566392b | ||
|
|
6fae670d19 | ||
|
|
b0431a51ca | ||
|
|
02e47ebd00 | ||
|
|
374c9ba658 | ||
|
|
adff7c0238 | ||
|
|
7e0c6bc952 | ||
|
|
0519734ea5 | ||
|
|
b385b580a6 | ||
|
|
91780d1c58 | ||
|
|
a6d8c00b1a | ||
|
|
1070d12732 | ||
|
|
a8216e78b1 | ||
|
|
c211767d47 | ||
|
|
34660eccf9 | ||
|
|
874122bad4 | ||
|
|
63ca84e5af | ||
|
|
d22874d039 | ||
|
|
128a35dff9 | ||
|
|
9e0987cd9b | ||
|
|
82a26ada65 | ||
|
|
9fa759173e | ||
|
|
a31a8c35c2 | ||
|
|
47f24f26aa | ||
|
|
6bd9f35bf3 | ||
|
|
590a5498ab | ||
|
|
d1e955c37b | ||
|
|
1783e54eb0 | ||
|
|
0bbf535b7b | ||
|
|
1f2d57d6a4 | ||
|
|
59f72bd991 | ||
|
|
9f3c4da588 | ||
|
|
9da3f92853 | ||
|
|
814faed08f | ||
|
|
c7fbaa4966 | ||
|
|
ab88dd19d3 | ||
|
|
eab1f4d366 | ||
|
|
c7c72d1a7a | ||
|
|
d914522ae4 | ||
|
|
3431e3f847 | ||
|
|
9d119577ea | ||
|
|
65e0970c41 | ||
|
|
03ab108a77 | ||
|
|
3c5710193c | ||
|
|
9a4a8aa71a | ||
|
|
30672654c5 | ||
|
|
039124bd07 | ||
|
|
5c9f96d12f | ||
|
|
2595cbc676 | ||
|
|
6a8542a6e9 | ||
|
|
a1699bdb88 | ||
|
|
a4595f0b32 | ||
|
|
c0c5cb8e2c | ||
|
|
aabfe79442 | ||
|
|
01c4a706a3 | ||
|
|
9a049d9774 | ||
|
|
47f2cacc6b | ||
|
|
be17771270 | ||
|
|
294bac537d | ||
|
|
b7feb6f6eb | ||
|
|
20d736db4c | ||
|
|
08babd2541 | ||
|
|
41230ef5dd | ||
|
|
e539c8c6c4 | ||
|
|
bf6951687d | ||
|
|
b5cfc72870 | ||
|
|
0bf9910ae9 | ||
|
|
b805eff032 | ||
|
|
df3bd393eb | ||
|
|
f3a6775098 | ||
|
|
c215bc3cd4 | ||
|
|
adfb5f1eae | ||
|
|
d663d42d23 | ||
|
|
7f3d4f0340 | ||
|
|
346c8f5e6e | ||
|
|
93eb6a5637 | ||
|
|
760cdd35c9 | ||
|
|
3ad2938dfa | ||
|
|
5a5137ded4 | ||
|
|
c2920ba84c | ||
|
|
39037eedd1 | ||
|
|
7c95194ec0 | ||
|
|
8fda127748 | ||
|
|
54bac2f07f | ||
|
|
8b0af9b5de | ||
|
|
02de96f012 | ||
|
|
e92ce38cf1 | ||
|
|
decb49a202 | ||
|
|
c7129fd377 | ||
|
|
4b3fa413a1 | ||
|
|
043a986ba9 | ||
|
|
7640e53102 | ||
|
|
b268f95e1f | ||
|
|
8dfdd1d106 | ||
|
|
80e0e2a13f | ||
|
|
5c65abfbac | ||
|
|
904cf15972 | ||
|
|
42dee34146 | ||
|
|
277abbfe7b | ||
|
|
00c8160f8e | ||
|
|
feeebfbc51 | ||
|
|
55f50ca4d1 | ||
|
|
0c366ce648 | ||
|
|
1b477fa40c | ||
|
|
a41c20d43b | ||
|
|
fe8008e67c | ||
|
|
4af362b751 | ||
|
|
8e3cb7bd9d | ||
|
|
c6f99c3a84 | ||
|
|
b8ee94d999 | ||
|
|
3308137d8d | ||
|
|
e944b68e8c | ||
|
|
e560229c83 | ||
|
|
18459deb77 | ||
|
|
a13bd1e251 | ||
|
|
7325189890 | ||
|
|
153b75f186 | ||
|
|
a42b61fa85 | ||
|
|
ce0f244c54 | ||
|
|
9fdf589976 | ||
|
|
ef339c9cc4 | ||
|
|
e5c4a3c7d5 | ||
|
|
036e621467 | ||
|
|
0b97c6438e | ||
|
|
6269cbf482 | ||
|
|
82f211f6b8 | ||
|
|
90e2258791 | ||
|
|
d197992dc8 | ||
|
|
9162cb8abe | ||
|
|
e839405202 | ||
|
|
5466d0a063 | ||
|
|
9270d3d56e | ||
|
|
7d8190f56e | ||
|
|
c313a1045d | ||
|
|
1be9a9e986 | ||
|
|
12e765dd27 | ||
|
|
a7f6082c9c | ||
|
|
2ebbbc5145 | ||
|
|
7db8f818bc | ||
|
|
55e3b64ff4 | ||
|
|
d035268c41 | ||
|
|
d0883c8cc7 | ||
|
|
2807202ee7 | ||
|
|
60f2e45d2d | ||
|
|
c222c46146 | ||
|
|
2b3e97b5a4 | ||
|
|
27b8e7a6f4 | ||
|
|
31359e9962 | ||
|
|
4d6d4b54d6 | ||
|
|
e060eabb01 | ||
|
|
09bdcefd4f | ||
|
|
2bbc42ce41 | ||
|
|
d17bd176a2 | ||
|
|
c2e48740fc | ||
|
|
bf24dc33f7 | ||
|
|
e3ad088ff3 | ||
|
|
1b8bdbe177 | ||
|
|
79b9d5af62 | ||
|
|
66f6cbad56 | ||
|
|
057c88ce52 | ||
|
|
3527d9d91c | ||
|
|
affe7f98b5 | ||
|
|
bcd7b5d194 | ||
|
|
9d443542f9 | ||
|
|
87db648f3e | ||
|
|
6b9fc81b64 | ||
|
|
e4909d0f2e | ||
|
|
9d18956b09 | ||
|
|
cd3bfe64d4 | ||
|
|
241f4d29b2 | ||
|
|
3851462b80 | ||
|
|
76e3294c8f | ||
|
|
d64256fb65 | ||
|
|
00adabc20d | ||
|
|
1cb402c410 | ||
|
|
e923e22c16 | ||
|
|
55cd8bee35 | ||
|
|
4323ab095f | ||
|
|
22dc8fa765 | ||
|
|
e98244adb5 | ||
|
|
92b62bf1fe | ||
|
|
2a84b6c6b2 | ||
|
|
285e3a8929 | ||
|
|
ab36b114fc | ||
|
|
d8a1dbb19c | ||
|
|
cffb115480 | ||
|
|
98b9e2faeb | ||
|
|
11638b7824 | ||
|
|
8fbdb50a9d | ||
|
|
5fbd8109f8 | ||
|
|
126ef094fc | ||
|
|
916ee6b394 | ||
|
|
2104327ba1 | ||
|
|
42eef0e9d6 | ||
|
|
e31fdfd0b3 | ||
|
|
697a9113c0 | ||
|
|
351dcfed01 | ||
|
|
fcfe516a2e | ||
|
|
9886e40395 | ||
|
|
a7811fb75b | ||
|
|
a79ef7fc29 | ||
|
|
15ce8ecfe9 | ||
|
|
92ea31c7b7 | ||
|
|
f4753030a2 | ||
|
|
3bfb687de3 | ||
|
|
eebad16636 | ||
|
|
564c8669f8 | ||
|
|
a7f0afceec | ||
|
|
1f8f0ae2d6 | ||
|
|
0e2840abce | ||
|
|
685dec022a | ||
|
|
e6e71a4953 | ||
|
|
4bd0a40037 | ||
|
|
b99fd93684 | ||
|
|
67c851792a | ||
|
|
3a75d70501 | ||
|
|
b7ef221b27 | ||
|
|
d51ae6b8bc | ||
|
|
61abc645e5 | ||
|
|
2a66c9b089 | ||
|
|
52d3b47f48 | ||
|
|
97bbd852b2 | ||
|
|
af95b35f27 | ||
|
|
c7bb3af760 | ||
|
|
0a3d0163d0 | ||
|
|
566f8b2e85 | ||
|
|
b2507066b6 | ||
|
|
e73900dad4 | ||
|
|
2fe2cd5337 | ||
|
|
04c3e2e407 | ||
|
|
a23d43bf05 | ||
|
|
934ef1d4c2 | ||
|
|
c8b6fe51d9 | ||
|
|
3fd3341ab9 | ||
|
|
060118c7e4 | ||
|
|
3651b8892f | ||
|
|
d49d84b250 | ||
|
|
0df4be849f | ||
|
|
ceaf3fba32 | ||
|
|
42c14b8078 | ||
|
|
9937f0c8bd | ||
|
|
bd1f5e7e16 | ||
|
|
f37fd7a7a3 | ||
|
|
378a49bf3c | ||
|
|
96e97c1a87 | ||
|
|
5f22259964 | ||
|
|
ab47e99215 | ||
|
|
1fcd6412fb | ||
|
|
ce0eec97db | ||
|
|
5d2f0b4e07 | ||
|
|
e79079d174 | ||
|
|
e94ebee15e | ||
|
|
5d878ce914 | ||
|
|
5ae152cdcf | ||
|
|
c6f7fe00fa | ||
|
|
45063aed44 | ||
|
|
5feb745b02 | ||
|
|
eda56b7af2 | ||
|
|
8f96ec255b | ||
|
|
ad0d9e4761 | ||
|
|
b5b60a6acf | ||
|
|
cb6b7f37e7 | ||
|
|
ef5a02c164 | ||
|
|
646421f71f | ||
|
|
4c881d8487 | ||
|
|
5aa901336c | ||
|
|
61c1bf0a41 | ||
|
|
d853c8568e | ||
|
|
b91396be8e | ||
|
|
7df127db31 | ||
|
|
8529f1b053 | ||
|
|
381a3392c6 | ||
|
|
a39b8fda70 | ||
|
|
1e1d7fe770 | ||
|
|
e6010bf75e | ||
|
|
d1fa53ca03 | ||
|
|
26c142df82 | ||
|
|
b61eacd3c5 | ||
|
|
1324eb5556 | ||
|
|
9cb3a3a182 | ||
|
|
f9423241d9 | ||
|
|
5b1e4c0324 | ||
|
|
acbddd2641 | ||
|
|
c821887160 | ||
|
|
4367dad669 | ||
|
|
0ebd3d92ba | ||
|
|
80ab7bf4e1 | ||
|
|
4a9ed4a204 | ||
|
|
f6f3d4262b | ||
|
|
75383c5c99 | ||
|
|
49261c9392 | ||
|
|
fe52e059b9 | ||
|
|
684e5922e8 | ||
|
|
7c1cf0a2dc | ||
|
|
dab167c0e3 | ||
|
|
326e3a33ac | ||
|
|
d44c07b9a7 | ||
|
|
22829b5529 | ||
|
|
c4cd02efc5 | ||
|
|
d1fd4058da | ||
|
|
08bd1f98e5 | ||
|
|
2d6eb3d8fc | ||
|
|
4daeda1490 | ||
|
|
c1925db067 | ||
|
|
cd24cbdbf4 | ||
|
|
d9b7e47824 | ||
|
|
b845134151 | ||
|
|
37bb9b76ab | ||
|
|
39ba5f90b1 | ||
|
|
e3ced21c9d | ||
|
|
66a0f2e7bd | ||
|
|
7c8b70eedb | ||
|
|
f12c428c78 | ||
|
|
7ee30554ad | ||
|
|
6b1042a6f9 | ||
|
|
ff857efdd2 | ||
|
|
0401a0a67c | ||
|
|
5873ee7691 | ||
|
|
da717977ed | ||
|
|
2b763fc452 | ||
|
|
b137a3326e | ||
|
|
970445fc48 | ||
|
|
e716c2ee35 | ||
|
|
e707ec0b1e | ||
|
|
05d44b2152 | ||
|
|
797577576e | ||
|
|
bd535bd51c | ||
|
|
166043593d | ||
|
|
9fd28f44df | ||
|
|
1ffe2d0927 | ||
|
|
735b4f0b7c | ||
|
|
1e71df5399 | ||
|
|
48948c91c3 | ||
|
|
1d73efee10 | ||
|
|
62f7cd213f | ||
|
|
91f6684fbf | ||
|
|
595b482478 | ||
|
|
ff51a23aea | ||
|
|
f7103a8629 | ||
|
|
4c9f9dafa6 | ||
|
|
b65e6a0453 | ||
|
|
ca95c8c3a3 | ||
|
|
3b8af033cd | ||
|
|
b3c87ea017 | ||
|
|
241d57aa9e | ||
|
|
ee8bb07122 | ||
|
|
c2ef6e343d | ||
|
|
192af01952 | ||
|
|
5293a2ab1c | ||
|
|
d5c2d5f291 | ||
|
|
4fe784de1f | ||
|
|
f289e9862a | ||
|
|
5fa707534a | ||
|
|
0a120bb5d0 | ||
|
|
19a5505c50 | ||
|
|
c9401be38e | ||
|
|
b922d8d8a6 | ||
|
|
b8cf7068c4 | ||
|
|
2d6a8391bf | ||
|
|
f4d487fb59 | ||
|
|
be7ee1ee65 | ||
|
|
3e2d3e4837 | ||
|
|
dfb4dde8fd | ||
|
|
159d64ddd3 | ||
|
|
1368b29596 | ||
|
|
c780985d3e | ||
|
|
71772e763a | ||
|
|
2d979a9ce9 | ||
|
|
2b273d8568 | ||
|
|
b725097409 | ||
|
|
772af52f4a | ||
|
|
db299ed761 | ||
|
|
0f274e5b22 | ||
|
|
e086cbb44b | ||
|
|
93c0a46a1d | ||
|
|
2cd663940a | ||
|
|
7bbf6cbfd1 | ||
|
|
46e86df420 | ||
|
|
d64f34b5d8 | ||
|
|
f65f7b3bbd | ||
|
|
c4727944df | ||
|
|
694cd6e9e8 | ||
|
|
465b8dc646 | ||
|
|
284d8d67bd | ||
|
|
b111521f40 | ||
|
|
6a7a15cf30 | ||
|
|
3df6942cde | ||
|
|
fc572832b1 | ||
|
|
46c0aeea67 | ||
|
|
a447f53b00 | ||
|
|
24ec78fd52 | ||
|
|
1393e55d53 | ||
|
|
5640d641d6 | ||
|
|
ecd847cad7 | ||
|
|
b867aa0410 | ||
|
|
8205c681eb | ||
|
|
c4ba8f8997 | ||
|
|
001bda28d9 | ||
|
|
1e7f3f1aac | ||
|
|
28eddd1670 | ||
|
|
a65f60a008 | ||
|
|
091425058b | ||
|
|
e89ad6c960 | ||
|
|
0fed861424 | ||
|
|
e78d580c06 | ||
|
|
e78d5b5462 | ||
|
|
20b7faaab7 | ||
|
|
5dad5e92a9 | ||
|
|
1553bad73a | ||
|
|
aadb65166d | ||
|
|
c8bc605f9e | ||
|
|
486b60486a | ||
|
|
13f0644aaa | ||
|
|
780442f0b3 | ||
|
|
27fa1f5c9c | ||
|
|
dede55d27d | ||
|
|
5c6c02fe03 | ||
|
|
9f3ef1b6ac | ||
|
|
5386cd9665 | ||
|
|
f2ee3c53a9 | ||
|
|
1bcca22719 | ||
|
|
6c1e8e8a66 | ||
|
|
9f69b12e5b | ||
|
|
ff3c8ccbe6 | ||
|
|
da5c61afe4 | ||
|
|
18bf0b80bc | ||
|
|
d220ce71b5 | ||
|
|
d6cbc710bd | ||
|
|
10ccd9f103 | ||
|
|
9e24257a4e | ||
|
|
aedf580a33 | ||
|
|
f713f06c62 | ||
|
|
899ae83acb | ||
|
|
3c1e0f0a8c | ||
|
|
0dc011c40c | ||
|
|
e455e28ff8 | ||
|
|
a4f8ad1bb0 | ||
|
|
0acf5e22bd | ||
|
|
df1099649c | ||
|
|
d1ad4a3ff0 | ||
|
|
2cf7d943df | ||
|
|
9b44ad6ce5 | ||
|
|
7789a32438 | ||
|
|
551cc01430 | ||
|
|
22058d09da | ||
|
|
80efa9a33e | ||
|
|
6a0976ca9d | ||
|
|
5847536c9d | ||
|
|
a5d1e2fd90 | ||
|
|
d8e3779010 | ||
|
|
7d50ab600f | ||
|
|
e3ec6f5292 | ||
|
|
9471287794 | ||
|
|
cbec8c1a89 | ||
|
|
4a7d8f628e | ||
|
|
b025e4c576 | ||
|
|
ee8fa3760d | ||
|
|
efaba68663 | ||
|
|
33effd31d5 | ||
|
|
271e7d50cf | ||
|
|
c235ec7421 | ||
|
|
6e28818ba9 | ||
|
|
95f3caaaa4 | ||
|
|
a7dd6e7c70 | ||
|
|
30ab347b78 | ||
|
|
9585c407e2 | ||
|
|
9efd1f5e9b | ||
|
|
21c5c2a54e | ||
|
|
a970957eef | ||
|
|
119e29ff1d | ||
|
|
7db760427c | ||
|
|
6d2ea9a200 | ||
|
|
0475834470 | ||
|
|
48f1ee4940 | ||
|
|
fb5f69f44e | ||
|
|
e0df9cbb01 | ||
|
|
1e56800543 | ||
|
|
28f30b7ef0 | ||
|
|
86355eb1ba | ||
|
|
bfbcb5362b | ||
|
|
8d2b4a9a25 | ||
|
|
da722b92c0 | ||
|
|
a4d7f3f907 | ||
|
|
6377b2ed95 | ||
|
|
dd52ef92a8 | ||
|
|
9ed72b43e8 | ||
|
|
f4bbe9c296 | ||
|
|
814126dc52 | ||
|
|
ff9246316f | ||
|
|
b92c433c50 | ||
|
|
7144ba1c10 | ||
|
|
0fad22512a | ||
|
|
4d9cde43be | ||
|
|
dc24bb63d6 | ||
|
|
5f296768a5 | ||
|
|
dd5fbc5859 | ||
|
|
280eff41f3 | ||
|
|
214e9103bf | ||
|
|
ac9dd92272 | ||
|
|
25ba629098 | ||
|
|
91d23ffc58 | ||
|
|
10f3d93df7 | ||
|
|
1c77e1a492 | ||
|
|
fbb741febb | ||
|
|
c5cc145538 | ||
|
|
0ef1ca0024 | ||
|
|
0a75a52b4a | ||
|
|
0d2d3360d0 | ||
|
|
15de778587 | ||
|
|
eeefe95958 | ||
|
|
5e65c186aa | ||
|
|
99dcdb87e3 | ||
|
|
58b3ae3136 | ||
|
|
7d6b0dd613 | ||
|
|
893fba8373 | ||
|
|
b46b6a8db9 | ||
|
|
44ad2b55e6 | ||
|
|
820532b7aa | ||
|
|
48281a17e4 | ||
|
|
d8c949e4d8 | ||
|
|
243a2b816e | ||
|
|
451176665c | ||
|
|
cff62f8d72 | ||
|
|
3f2ba221ef | ||
|
|
46713c3d7d | ||
|
|
b015204938 | ||
|
|
24f6bed855 | ||
|
|
5325e944e9 | ||
|
|
b488cb3d4b | ||
|
|
087c2afed1 | ||
|
|
b0645bd5d3 | ||
|
|
5a13dd090d | ||
|
|
b0455f4670 | ||
|
|
287f5b578c | ||
|
|
6839704c4b | ||
|
|
5332422239 | ||
|
|
7909c3e71b | ||
|
|
b45c82c256 | ||
|
|
3a5a82fd18 | ||
|
|
1238f5f23a | ||
|
|
ac9f5e9da4 | ||
|
|
58c392ae3b | ||
|
|
aa38ffc22d | ||
|
|
6d300527c8 | ||
|
|
a601c5cc81 | ||
|
|
4549fd7510 | ||
|
|
ef60eee57a | ||
|
|
7a9c13dee8 | ||
|
|
d652dd928a | ||
|
|
c99d6a8013 | ||
|
|
f8c5752472 | ||
|
|
44352a2861 | ||
|
|
7da874d835 | ||
|
|
de9e94de5f | ||
|
|
a151133161 | ||
|
|
042a2723ff | ||
|
|
2e6092b217 | ||
|
|
f658c32df1 | ||
|
|
b16874c5a8 | ||
|
|
b9a657db2c | ||
|
|
dbc613199b | ||
|
|
920c4206f4 | ||
|
|
fdb10c0679 | ||
|
|
325322898c | ||
|
|
27669c09ca | ||
|
|
0c59c57d66 | ||
|
|
26d7c4275a | ||
|
|
2b7a7599bb | ||
|
|
ed9c0ca87c | ||
|
|
68abbacc39 | ||
|
|
84d8e1841a | ||
|
|
a9b3139ff8 | ||
|
|
582b720183 | ||
|
|
0a02b55d95 | ||
|
|
20af6a7ce8 | ||
|
|
7c0f5c3237 | ||
|
|
f43449d333 | ||
|
|
e66287f92e | ||
|
|
f20626f17a | ||
|
|
ab00f8d15c | ||
|
|
58de758a32 | ||
|
|
8beaa211fb | ||
|
|
7c217324a6 | ||
|
|
15c1358aaf | ||
|
|
0a45325621 | ||
|
|
607eeaed4b | ||
|
|
c764adc256 | ||
|
|
27ee9c6eb0 | ||
|
|
8835e9d99f | ||
|
|
3ca507d73f | ||
|
|
3dc1074908 | ||
|
|
94d2bbb221 | ||
|
|
84dea7e971 | ||
|
|
781bbe2916 | ||
|
|
b0ae800d64 | ||
|
|
848a8e1180 | ||
|
|
fc0b68af28 | ||
|
|
c6f831e85f | ||
|
|
58173edb16 | ||
|
|
fc73bf0a0a | ||
|
|
458836abd3 | ||
|
|
5d7633d74c | ||
|
|
8f15eea910 | ||
|
|
d27746ee0b | ||
|
|
d13ce702a8 | ||
|
|
d262285827 | ||
|
|
b5a11a431e | ||
|
|
832d9de037 | ||
|
|
578863881f | ||
|
|
8875e1dc3b | ||
|
|
cd79ed32cb | ||
|
|
1924b7c945 | ||
|
|
d2bf50c63d | ||
|
|
b1dd4149a0 | ||
|
|
208ebd35b7 | ||
|
|
adda400602 | ||
|
|
a9d53dae72 | ||
|
|
ea0cde2cf4 | ||
|
|
e5ba82a44b | ||
|
|
364d6029b6 | ||
|
|
735223fc9f | ||
|
|
be9ac236fd | ||
|
|
ed7fa0ed22 | ||
|
|
3e4302e6ae | ||
|
|
1a38cb9e07 | ||
|
|
71ad5cb37a | ||
|
|
8a7c977942 | ||
|
|
63bacfacfd | ||
|
|
c8ec4595bb | ||
|
|
133ea3df09 | ||
|
|
f729a28f3c | ||
|
|
7ff11c3c88 | ||
|
|
5ab68d9a0d | ||
|
|
58fae896fe | ||
|
|
fea4fec0bc | ||
|
|
d853bbcf77 | ||
|
|
f82f2a0fe2 | ||
|
|
f69112cb3f | ||
|
|
6d77ad4be3 | ||
|
|
7a6a508066 | ||
|
|
cd019871e3 | ||
|
|
63b58cf6b5 | ||
|
|
3bbd966a82 | ||
|
|
5388d70bb1 | ||
|
|
5fd4467bf7 | ||
|
|
aa765e8fa3 | ||
|
|
232b61044c | ||
|
|
426cdbb3ae | ||
|
|
d83fe785c5 | ||
|
|
888cc309e0 | ||
|
|
4ed7b85ed8 | ||
|
|
647731e399 | ||
|
|
cd7d863f20 | ||
|
|
9d0f3623c3 | ||
|
|
e010a2d90b | ||
|
|
d704bc24f4 | ||
|
|
ff2fc586d5 | ||
|
|
78d305eb16 | ||
|
|
6b5c1810c0 | ||
|
|
e41912d6d4 | ||
|
|
97e0926696 | ||
|
|
8df407deb8 | ||
|
|
2ba405d5f8 | ||
|
|
658f41cb30 | ||
|
|
ebc0d09595 | ||
|
|
f7ea031dac | ||
|
|
b56b5885d0 | ||
|
|
a4c23d328c | ||
|
|
3cf14e8f9b | ||
|
|
c8886a0424 | ||
|
|
4f0dea3e7e | ||
|
|
9dd8ef4777 | ||
|
|
65c4ef91c7 | ||
|
|
32d3d7774a | ||
|
|
8664c8ac57 | ||
|
|
dea0cc01cf | ||
|
|
80f1590265 | ||
|
|
c25c5b543b | ||
|
|
8852b86ad8 | ||
|
|
a42fd30fc2 | ||
|
|
406dcbd8da | ||
|
|
de61f9fd81 | ||
|
|
57fe412619 | ||
|
|
b4ff29ac78 | ||
|
|
ba460de7ed | ||
|
|
c7768fde5d | ||
|
|
15f84a391d | ||
|
|
2b9c34b5c7 | ||
|
|
403b087e97 | ||
|
|
75aee1714b | ||
|
|
c41e86c990 | ||
|
|
4d8f0449d9 | ||
|
|
0db4077c3a | ||
|
|
f88aa35187 | ||
|
|
7d34c09e17 | ||
|
|
e11c4ecbaf | ||
|
|
553ed1416c | ||
|
|
688f5051e6 | ||
|
|
adb666e67f | ||
|
|
07e2072692 | ||
|
|
1c14cd6c8b | ||
|
|
744b54a829 | ||
|
|
a90c463abe | ||
|
|
6bf21f1610 | ||
|
|
364ee1ffae | ||
|
|
88faef3ba9 | ||
|
|
bcc6b524fb | ||
|
|
61b38b9f05 | ||
|
|
fce57abeca | ||
|
|
946e9b0c80 | ||
|
|
748ed6cd81 | ||
|
|
49f174cdad | ||
|
|
6ca8d31c83 | ||
|
|
aa1fa7468b | ||
|
|
2d048f1f34 | ||
|
|
3d1cc16a9b | ||
|
|
cbe86e04b3 | ||
|
|
a558e560bd | ||
|
|
cfe4152b1d | ||
|
|
91c2a8d90b | ||
|
|
2c8f907b2c | ||
|
|
669f4b867f | ||
|
|
5fae286cf4 | ||
|
|
a2c90aad86 | ||
|
|
898621d0a1 | ||
|
|
e1c1d869de | ||
|
|
25e2cd0db6 | ||
|
|
1f8ef4c903 | ||
|
|
d9511d817a | ||
|
|
2fda70fb4a | ||
|
|
02f618d52c | ||
|
|
61c47e4cae | ||
|
|
e6b216bdbb | ||
|
|
192727e152 | ||
|
|
cb00d3e66c | ||
|
|
987e5e8f13 | ||
|
|
df0bc8c3af | ||
|
|
983120102c | ||
|
|
86c0b69390 | ||
|
|
d5989a0de4 | ||
|
|
1b747c526c | ||
|
|
5cbabdf4c9 | ||
|
|
9ef4e74ba2 | ||
|
|
0321171113 | ||
|
|
d542621155 | ||
|
|
4bbf8acc9b | ||
|
|
a21556314d | ||
|
|
99d3d7f914 | ||
|
|
86d9e0a97a | ||
|
|
db0ff96200 | ||
|
|
808e625d9d | ||
|
|
dc06704ec7 | ||
|
|
5ef3c1b09b | ||
|
|
fe451c30f8 | ||
|
|
6f2848f4a6 | ||
|
|
d63ce62916 | ||
|
|
c7d6a5ae4d | ||
|
|
d5e970b93f | ||
|
|
4cb49f5561 | ||
|
|
c347b720a9 | ||
|
|
27a1729f6d | ||
|
|
a1f5c1dee7 | ||
|
|
20179b7991 | ||
|
|
adffa9b0f4 | ||
|
|
2e37f65bdc | ||
|
|
4ab62a6bd2 | ||
|
|
07427ae9d0 | ||
|
|
8f55d94d40 |
@@ -2,11 +2,13 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
max_line_length = 80
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
max_line_length = 0
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto
|
||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -13,13 +13,9 @@ docs/code
|
||||
docs/_site
|
||||
docs/.sass-cache
|
||||
docs/css/react.css
|
||||
docs/js/.module-cache
|
||||
docs/js/JSXTransformer.js
|
||||
docs/js/react.min.js
|
||||
docs/js/docs.js
|
||||
docs/js/jsx-compiler.js
|
||||
docs/js/live_editor.js
|
||||
docs/js/examples
|
||||
docs/js/*
|
||||
docs/downloads
|
||||
examples/shared/*.js
|
||||
|
||||
test/the-files-to-test.generated.js
|
||||
*.log*
|
||||
chrome-user-data
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"noempty": true,
|
||||
"nonstandard": true,
|
||||
"onecase": true,
|
||||
"sub": true,
|
||||
"regexdash": true,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
|
||||
42
.mailmap
Normal file
42
.mailmap
Normal file
@@ -0,0 +1,42 @@
|
||||
Ben Newman <bn@cs.stanford.edu> <benjamn@fb.com>
|
||||
Cheng Lou <chenglou92@gmail.com> <chenglou@fb.com>
|
||||
Christoph Pojer <christoph.pojer@gmail.com>
|
||||
Christoph Pojer <christoph.pojer@gmail.com> <cpojer@fb.com>
|
||||
Connor McSheffrey <c@conr.me> <connor.mcsheffrey@gmail.com>
|
||||
Dan Schafer <dschafer@fb.com>
|
||||
Fabio M. Costa <fabiomcosta@gmail.com> <fabs@fb.com>
|
||||
Harry Hull <harry.hull1@gmail.com>
|
||||
Ingvar Stepanyan <me@rreverser.com> <rreverser@ubuntu.rreverser.a4.internal.cloudapp.net>
|
||||
Jason Bonta <jbonta@gmail.com> <jasonbonta@fb.com>
|
||||
Jason Trill <jason@jasontrill.com>
|
||||
Jeff Morrison <jeff@anafx.com> <Jeff@anafx.com>
|
||||
Jeff Morrison <jeff@anafx.com> <jeffmo@fb.com>
|
||||
Jeffrey Lin <lin.jeffrey@gmail.com> <jeffreylin@fb.com>
|
||||
Jonathan Hsu <jhiswin@gmail.com>
|
||||
Jordan Walke <jordojw@gmail.com>
|
||||
Jordan Walke <jordojw@gmail.com> <jordanjcw@fb.com>
|
||||
Josh Duck <josh@fb.com> <github@joshduck.com>
|
||||
Jun Wu <quark@lihdd.net>
|
||||
Keito Uchiyama <projects@keito.me> <keito@fb.com>
|
||||
Laurence Rowe <l@lrowe.co.uk> <laurence@lrowe.co.uk>
|
||||
Martin Andert <mandert@gmail.com>
|
||||
Michal Srb <xixixao@seznam.cz> xixixao <xixixao@seznam.cz>
|
||||
Nick Gavalas <njg57@cornell.edu>
|
||||
Nick Thompson <ncthom91@gmail.com> <nickt@instagram.com>
|
||||
Paul O’Shannessy <paul@oshannessy.com> <poshannessy@fb.com>
|
||||
Paul Shen <paul@mnml0.com> <paulshen@fb.com>
|
||||
Pete Hunt <floydophone@gmail.com>
|
||||
Pete Hunt <floydophone@gmail.com> <pete.hunt@fb.com>
|
||||
Pete Hunt <floydophone@gmail.com> <pete@instagram.com>
|
||||
Pete Hunt <floydophone@gmail.com> <phunt@instagram.com>
|
||||
Petri Lievonen <plievone@cc.hut.fi>
|
||||
Pieter Vanderwerff <me@pieter.io> <pieter@heyday.co.nz>
|
||||
Richard Feldman <richard.t.feldman@gmail.com> <richard@noredink.com>
|
||||
Richard Livesey <Livesey7@hotmail.co.uk>
|
||||
Sander Spies <sandermail@gmail.com>
|
||||
Sebastian Markbåge <sebastian@calyptus.eu> <sema@fb.com>
|
||||
Stoyan Stefanov <ssttoo@ymail.com>
|
||||
Thomas Aylott <oblivious@subtlegradient.com> <aylott@fb.com>
|
||||
Timothy Yung <yungsters@gmail.com> <yungsters@fb.com>
|
||||
Vjeux <vjeuxx@gmail.com>
|
||||
Vjeux <vjeuxx@gmail.com> <vjeux@fb.com>
|
||||
55
.travis.yml
55
.travis.yml
@@ -2,13 +2,62 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
script:
|
||||
- |
|
||||
grunt $TEST_TYPE
|
||||
after_script:
|
||||
- curl -F "react=@build/react.js" -F "react.min=@build/react.min.js" -F "transformer=@build/JSXTransformer.js"
|
||||
-F "commit=$TRAVIS_COMMIT" -F "date=`git log --format='%ct' -1`" -F "pull_request=$TRAVIS_PULL_REQUEST"
|
||||
-F "token=$SECRET_TOKEN" -F "branch=$TRAVIS_BRANCH" $SERVER
|
||||
- |
|
||||
if [ "$TEST_TYPE" = test:full ] && [ "$SERVER" ]; then
|
||||
grunt build
|
||||
curl \
|
||||
-F "react=@build/react.js" \
|
||||
-F "react.min=@build/react.min.js" \
|
||||
-F "transformer=@build/JSXTransformer.js" \
|
||||
-F "react-with-addons=@build/react-with-addons.js" \
|
||||
-F "react-with-addons.min=@build/react-with-addons.min.js" \
|
||||
-F "npm-react=@build/react.tgz" \
|
||||
-F "npm-react-tools=@build/react-tools.tgz" \
|
||||
-F "commit=$TRAVIS_COMMIT" \
|
||||
-F "date=`git log --format='%ct' -1`" \
|
||||
-F "pull_request=$TRAVIS_PULL_REQUEST" \
|
||||
-F "token=$SECRET_TOKEN" \
|
||||
-F "branch=$TRAVIS_BRANCH" \
|
||||
$SERVER
|
||||
fi
|
||||
env:
|
||||
matrix:
|
||||
- TEST_TYPE=test:full
|
||||
- TEST_TYPE=lint
|
||||
- TEST_TYPE=perf:full
|
||||
- TEST_TYPE=test:coverage
|
||||
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie11
|
||||
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie10
|
||||
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie9
|
||||
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie8
|
||||
- TEST_TYPE=test:webdriver:saucelabs:ios
|
||||
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=safari
|
||||
global:
|
||||
# SERVER
|
||||
- secure: qPvsJ46XzGrdIuPA70b55xQNGF8jcK7N1LN5CCQYYocXLa+fBrl+fTE77QvehOPhqwJXcj6kOxI+sY0KrVwV7gmq2XY2HZGWUSCxTN0SZlNIzqPA80Y7G/yOjA4PUt8LKgP+8tptyhTAY56qf+hgW8BoLiKOdztYF2p+3zXOLuA=
|
||||
# SECRET_TOKEN
|
||||
- secure: dkpPW+VnoqC/okhRdV90m36NcyBFhcwEKL3bNFExAwi0dXnFao8RoFlvnwiPlA23h2faROkMIetXlti6Aju08BgUFV+f9aL6vLyU7gUent4Nd3413zf2fwDtXIWIETg6uLnOpSykGKgCAT/hY3Q2oPLqOoY0OxfgnbqwxkxljrE=
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- env: TEST_TYPE=lint
|
||||
- env: TEST_TYPE=test:coverage
|
||||
- env: TEST_TYPE=perf:full
|
||||
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie11
|
||||
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie10
|
||||
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie9
|
||||
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie8
|
||||
- env: TEST_TYPE=test:webdriver:saucelabs:ios
|
||||
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=safari
|
||||
notifications:
|
||||
irc:
|
||||
use_notice: true
|
||||
skip_join: true
|
||||
on_success: change
|
||||
on_failure: change
|
||||
channels:
|
||||
- chat.freenode.net#reactjs
|
||||
|
||||
109
AUTHORS
Normal file
109
AUTHORS
Normal file
@@ -0,0 +1,109 @@
|
||||
Alan deLevie <adelevie@gmail.com>
|
||||
Alex Zelenskiy <azelenskiy@fb.com>
|
||||
Alexander Solovyov <alexander@solovyov.net>
|
||||
Andreas Svensson <andreas@syranide.com>
|
||||
Andrew Davey <andrew@equin.co.uk>
|
||||
Andrew Zich <azich@fb.com>
|
||||
Andrey Popp <8mayday@gmail.com>
|
||||
Ayman Osman <aymano.osman@gmail.com>
|
||||
Ben Alpert <spicyjalapeno@gmail.com>
|
||||
Ben Newman <bn@cs.stanford.edu>
|
||||
Ben Ripkens <bripkens.dev@gmail.com>
|
||||
Bob Eagan <bob@synapsestudios.com>
|
||||
Brian Cooke <bri@bricooke.com>
|
||||
Brian Kim <briankimpossible@gmail.com>
|
||||
Brian Rue <brian@rollbar.com>
|
||||
Cam Spiers <camspiers@gmail.com>
|
||||
Cat Chen <catchen@fb.com>
|
||||
Cheng Lou <chenglou92@gmail.com>
|
||||
Christian Roman <chroman16@gmail.com>
|
||||
Christoph Pojer <christoph.pojer@gmail.com>
|
||||
Clay Allsopp <clay.allsopp@gmail.com>
|
||||
Connor McSheffrey <c@conr.me>
|
||||
Dan Schafer <dschafer@fb.com>
|
||||
Daniel Gasienica <dgasienica@zynga.com>
|
||||
Daniel Lo Nigro <danlo@fb.com>
|
||||
Daniel Miladinov <dmiladinov@wingspan.com>
|
||||
Danny Ben-David <dannybd@fb.com>
|
||||
David Hellsing <david@aino.se>
|
||||
David Hu <davidhu91@gmail.com>
|
||||
Dustin Getz <dgetz@wingspan.com>
|
||||
Eric Clemmons <eric@smarterspam.com>
|
||||
Eric Schoffstall <contra@wearefractal.com>
|
||||
Fabio M. Costa <fabiomcosta@gmail.com>
|
||||
Felipe Oliveira Carvalho <felipekde@gmail.com>
|
||||
Felix Kling <fkling@fb.com>
|
||||
Fernando Correia <fernando@servicero.com>
|
||||
Greg Roodt <groodt@gmail.com>
|
||||
Guido Bouman <m@guido.vc>
|
||||
Harry Hull <harry.hull1@gmail.com>
|
||||
Hugo Jobling <me@thisishugo.com>
|
||||
Ian Obermiller <iano@fb.com>
|
||||
Ingvar Stepanyan <me@rreverser.com>
|
||||
Isaac Salier-Hellendag <isaac@fb.com>
|
||||
Ivan Kozik <ivan@ludios.org>
|
||||
Jakub Malinowski <jakubmal@gmail.com>
|
||||
James Ide <ide@fb.com>
|
||||
Jamie Wong <jamie.lf.wong@gmail.com>
|
||||
Jamison Dance <jergason@gmail.com>
|
||||
Jan Kassens <jkassens@fb.com>
|
||||
Jared Forsyth <jared@jaredforsyth.com>
|
||||
Jason Bonta <jbonta@gmail.com>
|
||||
Jason Trill <jason@jasontrill.com>
|
||||
Jean Lauliac <lauliacj@gmail.com>
|
||||
Jeff Morrison <jeff@anafx.com>
|
||||
Jeffrey Lin <lin.jeffrey@gmail.com>
|
||||
Jignesh Kakadiya <jigneshhk1992@gmail.com>
|
||||
Johannes Baiter <johannes.baiter@gmail.com>
|
||||
John Watson <jwatson@fb.com>
|
||||
Jonas Gebhardt <jonas@instagram.com>
|
||||
Jonathan Hsu <jhiswin@gmail.com>
|
||||
Jordan Walke <jordojw@gmail.com>
|
||||
Josh Duck <josh@fb.com>
|
||||
Jun Wu <quark@lihdd.net>
|
||||
Keito Uchiyama <projects@keito.me>
|
||||
Kit Randel <kit@nocturne.net.nz>
|
||||
Kunal Mehta <k.mehta@berkeley.edu>
|
||||
Laurence Rowe <l@lrowe.co.uk>
|
||||
Levi McCallum <levi@levimccallum.com>
|
||||
Logan Allen <loganfynne@gmail.com>
|
||||
Luigy Leon <luichi.19@gmail.com>
|
||||
Mark Richardson <echo@fb.com>
|
||||
Marshall Roch <mroch@fb.com>
|
||||
Martin Andert <mandert@gmail.com>
|
||||
Martin Konicek <mkonicek@fb.com>
|
||||
Mathieu M-Gosselin <mathieumg@gmail.com>
|
||||
Matt Harrison <mt.harrison86@gmail.com>
|
||||
Matti Nelimarkka <matti.nelimarkka@hiit.fi>
|
||||
Michal Srb <xixixao@seznam.cz>
|
||||
Mouad Debbar <mdebbar@fb.com>
|
||||
Nadeesha Cabral <nadeesha.cabral@gmail.com>
|
||||
Nicholas Bergson-Shilcock <me@nicholasbs.net>
|
||||
Nick Gavalas <njg57@cornell.edu>
|
||||
Nick Thompson <ncthom91@gmail.com>
|
||||
Owen Coutts <owenc@fb.com>
|
||||
Pascal Hartig <passy@twitter.com>
|
||||
Paul O’Shannessy <paul@oshannessy.com>
|
||||
Paul Seiffert <paul.seiffert@gmail.com>
|
||||
Paul Shen <paul@mnml0.com>
|
||||
Pete Hunt <floydophone@gmail.com>
|
||||
Peter Cottle <pcottle@fb.com>
|
||||
Petri Lievonen <plievone@cc.hut.fi>
|
||||
Pieter Vanderwerff <me@pieter.io>
|
||||
Richard D. Worth <rdworth@gmail.com>
|
||||
Richard Feldman <richard.t.feldman@gmail.com>
|
||||
Richard Livesey <Livesey7@hotmail.co.uk>
|
||||
Sander Spies <sandermail@gmail.com>
|
||||
Sean Kinsey <oyvind@fb.com>
|
||||
Sebastian Markbåge <sebastian@calyptus.eu>
|
||||
Shaun Trennery <shaun.trennery@gmail.com>
|
||||
Simon Højberg <r.hackr@gmail.com>
|
||||
Stoyan Stefanov <ssttoo@ymail.com>
|
||||
Sundeep Malladi <sundeep.malladi@gmail.com>
|
||||
Thomas Aylott <oblivious@subtlegradient.com>
|
||||
Timothy Yung <yungsters@gmail.com>
|
||||
Tom Occhino <tomocchino@gmail.com>
|
||||
Vjeux <vjeuxx@gmail.com>
|
||||
Wincent Colaiuta <win@wincent.com>
|
||||
Zach Bruggeman <zbruggeman@me.com>
|
||||
imagentleman <imagentlemail@gmail.com>
|
||||
182
CHANGELOG.md
182
CHANGELOG.md
@@ -1,3 +1,185 @@
|
||||
## 0.9.0 (February 20, 2014)
|
||||
|
||||
### React Core
|
||||
|
||||
#### Breaking Changes
|
||||
|
||||
- The lifecycle methods `componentDidMount` and `componentDidUpdate` no longer receive the root node as a parameter; use `this.getDOMNode()` instead
|
||||
- Whenever a prop is equal to `undefined`, the default value returned by `getDefaultProps` will now be used instead
|
||||
- `React.unmountAndReleaseReactRootNode` was previously deprecated and has now been removed
|
||||
- `React.renderComponentToString` is now synchronous and returns the generated HTML string
|
||||
- Full-page rendering (that is, rendering the `<html>` tag using React) is now supported only when starting with server-rendered markup
|
||||
- On mouse wheel events, `deltaY` is no longer negated
|
||||
- When prop types validation fails, a warning is logged instead of an error thrown (with the production build of React, type checks are now skipped for performance)
|
||||
- On `input`, `select`, and `textarea` elements, `.getValue()` is no longer supported; use `.getDOMNode().value` instead
|
||||
- `this.context` on components is now reserved for internal use by React
|
||||
|
||||
#### New Features
|
||||
|
||||
- React now never rethrows errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly
|
||||
- Added support for SVG tags `defs`, `linearGradient`, `polygon`, `radialGradient`, `stop`
|
||||
- Added support for more attributes:
|
||||
- `crossOrigin` for CORS requests
|
||||
- `download` and `hrefLang` for `<a>` tags
|
||||
- `mediaGroup` and `muted` for `<audio>` and `<video>` tags
|
||||
- `noValidate` and `formNoValidate` for forms
|
||||
- `property` for Open Graph `<meta>` tags
|
||||
- `sandbox`, `seamless`, and `srcDoc` for `<iframe>` tags
|
||||
- `scope` for screen readers
|
||||
- `span` for `<colgroup>` tags
|
||||
- Added support for defining `propTypes` in mixins
|
||||
- Added `any`, `arrayOf`, `component`, `oneOfType`, `renderable`, `shape` to `React.PropTypes`
|
||||
- Added support for `statics` on component spec for static component methods
|
||||
- On all events, `.currentTarget` is now properly set
|
||||
- On keyboard events, `.key` is now polyfilled in all browsers for special (non-printable) keys
|
||||
- On clipboard events, `.clipboardData` is now polyfilled in IE
|
||||
- On drag events, `.dragTransfer` is now present
|
||||
- Added support for `onMouseOver` and `onMouseOut` in addition to the existing `onMouseEnter` and `onMouseLeave` events
|
||||
- Added support for `onLoad` and `onError` on `<img>` elements
|
||||
- Added support for `onReset` on `<form>` elements
|
||||
- The `autoFocus` attribute is now polyfilled consistently on `input`, `select`, and `textarea`
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
- React no longer adds an `__owner__` property to each component's `props` object; passed-in props are now never mutated
|
||||
- When nesting top-level components (e.g., calling `React.renderComponent` within `componentDidMount`), events now properly bubble to the parent component
|
||||
- Fixed a case where nesting top-level components would throw an error when updating
|
||||
- Passing an invalid or misspelled propTypes type now throws an error
|
||||
- On mouse enter/leave events, `.target`, `.relatedTarget`, and `.type` are now set properly
|
||||
- On composition events, `.data` is now properly normalized in IE9 and IE10
|
||||
- CSS property values no longer have `px` appended for the unitless properties `columnCount`, `flex`, `flexGrow`, `flexShrink`, `lineClamp`, `order`, `widows`
|
||||
- Fixed a memory leak when unmounting children with a `componentWillUnmount` handler
|
||||
- Fixed a memory leak when `renderComponentToString` would store event handlers
|
||||
- Fixed an error that could be thrown when removing form elements during a click handler
|
||||
- Boolean attributes such as `disabled` are rendered without a value (previously `disabled="true"`, now simply `disabled`)
|
||||
- `key` values containing `.` are now supported
|
||||
- Shortened `data-reactid` values for performance
|
||||
- Components now always remount when the `key` property changes
|
||||
- Event handlers are attached to `document` only when necessary, improving performance in some cases
|
||||
- Events no longer use `.returnValue` in modern browsers, eliminating a warning in Chrome
|
||||
- `scrollLeft` and `scrollTop` are no longer accessed on document.body, eliminating a warning in Chrome
|
||||
- General performance fixes, memory optimizations, improvements to warnings and error messages
|
||||
|
||||
### React with Addons
|
||||
|
||||
- `React.addons.TestUtils` was added to help write unit tests
|
||||
- `React.addons.TransitionGroup` was renamed to `React.addons.CSSTransitionGroup`
|
||||
- `React.addons.TransitionGroup` was added as a more general animation wrapper
|
||||
- `React.addons.cloneWithProps` was added for cloning components and modifying their props
|
||||
- Bug fix for adding back nodes during an exit transition for CSSTransitionGroup
|
||||
- Bug fix for changing `transitionLeave` in CSSTransitionGroup
|
||||
- Performance optimizations for CSSTransitionGroup
|
||||
- On checkbox `<input>` elements, `checkedLink` is now supported for two-way binding
|
||||
|
||||
### JSX Compiler and react-tools Package
|
||||
|
||||
- Whitespace normalization has changed; now space between two tags on the same line will be preserved, while newlines between two tags will be removed
|
||||
- The `react-tools` npm package no longer includes the React core libraries; use the `react` package instead.
|
||||
- `displayName` is now added in more cases, improving error messages and names in the React Dev Tools
|
||||
- Fixed an issue where an invalid token error was thrown after a JSX closing tag
|
||||
- `JSXTransformer` now uses source maps automatically in modern browsers
|
||||
- `JSXTransformer` error messages now include the filename and problematic line contents when a file fails to parse
|
||||
|
||||
## 0.8.0 (December 19, 2013)
|
||||
|
||||
### React
|
||||
|
||||
* Added support for more attributes:
|
||||
* `rows` & `cols` for `<textarea>`
|
||||
* `defer` & `async` for `<script>`
|
||||
* `loop` for `<audio>` & `<video>`
|
||||
* `autoCorrect` for form fields (a non-standard attribute only supported by mobile WebKit)
|
||||
* Improved error messages
|
||||
* Fixed Selection events in IE11
|
||||
* Added `onContextMenu` events
|
||||
|
||||
### React with Addons
|
||||
|
||||
* Fixed bugs with TransitionGroup when children were undefined
|
||||
* Added support for `onTransition`
|
||||
|
||||
### react-tools
|
||||
|
||||
* Upgraded `jstransform` and `esprima-fb`
|
||||
|
||||
### JSXTransformer
|
||||
|
||||
* Added support for use in IE8
|
||||
* Upgraded browserify, which reduced file size by ~65KB (16KB gzipped)
|
||||
|
||||
|
||||
## 0.5.2, 0.4.2 (December 18, 2013)
|
||||
|
||||
### React
|
||||
|
||||
* Fixed a potential XSS vulnerability when using user content as a `key`: [CVE-2013-7035](https://groups.google.com/forum/#!topic/reactjs/OIqxlB2aGfU)
|
||||
|
||||
|
||||
## 0.5.1 (October 29, 2013)
|
||||
|
||||
### React
|
||||
|
||||
* Fixed bug with `<input type="range">` and selection events.
|
||||
* Fixed bug with selection and focus.
|
||||
* Made it possible to unmount components from the document root.
|
||||
* Fixed bug for `disabled` attribute handling on non-`<input>` elements.
|
||||
|
||||
### React with Addons
|
||||
|
||||
* Fixed bug with transition and animation event detection.
|
||||
|
||||
|
||||
## 0.5.0 (October 16, 2013)
|
||||
|
||||
### React
|
||||
|
||||
* Memory usage improvements - reduced allocations in core which will help with GC pauses
|
||||
* Performance improvements - in addition to speeding things up, we made some tweaks to stay out of slow path code in V8 and Nitro.
|
||||
* Standardized prop -> DOM attribute process. This previously resulting in additional type checking and overhead as well as confusing cases for users. Now we will always convert your value to a string before inserting it into the DOM.
|
||||
* Support for Selection events.
|
||||
* Support for [Composition events](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent).
|
||||
* Support for additional DOM properties (`charSet`, `content`, `form`, `httpEquiv`, `rowSpan`, `autoCapitalize`).
|
||||
* Support for additional SVG properties (`rx`, `ry`).
|
||||
* Support for using `getInitialState` and `getDefaultProps` in mixins.
|
||||
* Support mounting into iframes.
|
||||
* Bug fixes for controlled form components.
|
||||
* Bug fixes for SVG element creation.
|
||||
* Added `React.version`.
|
||||
* Added `React.isValidClass` - Used to determine if a value is a valid component constructor.
|
||||
* Removed `React.autoBind` - This was deprecated in v0.4 and now properly removed.
|
||||
* Renamed `React.unmountAndReleaseReactRootNode` to `React.unmountComponentAtNode`.
|
||||
* Began laying down work for refined performance analysis.
|
||||
* Better support for server-side rendering - [react-page](https://github.com/facebook/react-page) has helped improve the stability for server-side rendering.
|
||||
* Made it possible to use React in environments enforcing a strict [Content Security Policy](https://developer.mozilla.org/en-US/docs/Security/CSP/Introducing_Content_Security_Policy). This also makes it possible to use React to build Chrome extensions.
|
||||
|
||||
### React with Addons (New!)
|
||||
|
||||
* Introduced a separate build with several "addons" which we think can help improve the React experience. We plan to deprecate this in the long-term, instead shipping each as standalone pieces. [Read more in the docs](http://facebook.github.io/react/docs/addons.html).
|
||||
|
||||
### JSX
|
||||
|
||||
* No longer transform `class` to `className` as part of the transform! This is a breaking change - if you were using `class`, you *must* change this to `className` or your components will be visually broken.
|
||||
* Added warnings to the in-browser transformer to make it clear it is not intended for production use.
|
||||
* Improved compatibility for Windows
|
||||
* Improved support for maintaining line numbers when transforming.
|
||||
|
||||
|
||||
## 0.4.1 (July 26, 2013)
|
||||
|
||||
### React
|
||||
|
||||
* `setState` callbacks are now executed in the scope of your component.
|
||||
* `click` events now work on Mobile Safari.
|
||||
* Prevent a potential error in event handling if `Object.prototype` is extended.
|
||||
* Don't set DOM attributes to the string `"undefined"` on update when previously defined.
|
||||
* Improved support for `<iframe>` attributes.
|
||||
* Added checksums to detect and correct cases where server-side rendering markup mismatches what React expects client-side.
|
||||
|
||||
### JSXTransformer
|
||||
|
||||
* Improved environment detection so it can be run in a non-browser environment.
|
||||
|
||||
|
||||
## 0.4.0 (July 17, 2013)
|
||||
|
||||
### React
|
||||
|
||||
@@ -57,6 +57,7 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
|
||||
* `"use strict";`
|
||||
* 80 character line length
|
||||
* "Attractive"
|
||||
* Do not use the optional parameters of `setTimeout` and `setInterval`
|
||||
|
||||
## License
|
||||
|
||||
|
||||
178
Gruntfile.js
178
Gruntfile.js
@@ -3,76 +3,200 @@
|
||||
var exec = require('child_process').exec;
|
||||
var jsxTask = require('./grunt/tasks/jsx');
|
||||
var browserifyTask = require('./grunt/tasks/browserify');
|
||||
var wrapupTask = require('./grunt/tasks/wrapup');
|
||||
var populistTask = require('./grunt/tasks/populist');
|
||||
var phantomTask = require('./grunt/tasks/phantom');
|
||||
var webdriverPhantomJSTask = require('./grunt/tasks/webdriver-phantomjs');
|
||||
var webdriverJasmineTasks = require('./grunt/tasks/webdriver-jasmine');
|
||||
var sauceTunnelTask = require('./grunt/tasks/sauce-tunnel');
|
||||
var npmTask = require('./grunt/tasks/npm');
|
||||
var releaseTasks = require('./grunt/tasks/release');
|
||||
var npmReactTasks = require('./grunt/tasks/npm-react');
|
||||
var npmReactToolsTasks = require('./grunt/tasks/npm-react-tools');
|
||||
var versionCheckTask = require('./grunt/tasks/version-check');
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
copy: require('./grunt/config/copy'),
|
||||
jsx: require('./grunt/config/jsx/jsx'),
|
||||
jsx: require('./grunt/config/jsx'),
|
||||
browserify: require('./grunt/config/browserify'),
|
||||
wrapup: require('./grunt/config/wrapup'),
|
||||
populist: require('./grunt/config/populist'),
|
||||
phantom: require('./grunt/config/phantom'),
|
||||
connect: require('./grunt/config/server')(grunt),
|
||||
"webdriver-jasmine": require('./grunt/config/webdriver-jasmine'),
|
||||
"webdriver-perf": require('./grunt/config/webdriver-perf'),
|
||||
npm: require('./grunt/config/npm'),
|
||||
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js'],
|
||||
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js', '.module-cache'],
|
||||
jshint: require('./grunt/config/jshint'),
|
||||
compare_size: require('./grunt/config/compare_size')
|
||||
compare_size: require('./grunt/config/compare_size'),
|
||||
complexity: require('./grunt/config/complexity')
|
||||
});
|
||||
|
||||
grunt.config.set('compress', require('./grunt/config/compress'));
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||
grunt.loadNpmTasks('grunt-compare-size');
|
||||
grunt.loadNpmTasks('grunt-contrib-compress');
|
||||
Object.keys(grunt.file.readJSON('package.json').devDependencies)
|
||||
.filter(function(npmTaskName) { return npmTaskName.indexOf('grunt-') === 0; })
|
||||
.filter(function(npmTaskName) { return npmTaskName != 'grunt-cli'; })
|
||||
.forEach(function(npmTaskName) { grunt.loadNpmTasks(npmTaskName); });
|
||||
|
||||
// Alias 'jshint' to 'lint' to better match the workflow we know
|
||||
grunt.registerTask('lint', ['jshint']);
|
||||
|
||||
// Register jsx:debug and :release tasks.
|
||||
grunt.registerTask('download-previous-version', require('./grunt/tasks/download-previous-version.js'));
|
||||
|
||||
grunt.registerTask('delete-build-modules', function() {
|
||||
if (grunt.file.exists('build/modules')) {
|
||||
grunt.file.delete('build/modules');
|
||||
}
|
||||
});
|
||||
|
||||
// Register jsx:normal and :release tasks.
|
||||
grunt.registerMultiTask('jsx', jsxTask);
|
||||
|
||||
// Our own browserify-based tasks to build a single JS file build
|
||||
grunt.registerMultiTask('browserify', browserifyTask);
|
||||
|
||||
// Similar to Browserify, use WrapUp to generate single JS file that
|
||||
// defines global variables instead of using require.
|
||||
grunt.registerMultiTask('wrapup', wrapupTask);
|
||||
|
||||
grunt.registerMultiTask('populist', populistTask);
|
||||
|
||||
grunt.registerMultiTask('phantom', phantomTask);
|
||||
grunt.registerTask('sauce-tunnel', sauceTunnelTask);
|
||||
|
||||
grunt.registerMultiTask('webdriver-jasmine', webdriverJasmineTasks);
|
||||
|
||||
grunt.registerMultiTask('webdriver-perf', require('./grunt/tasks/webdriver-perf'));
|
||||
|
||||
grunt.registerMultiTask('npm', npmTask);
|
||||
|
||||
grunt.registerTask('build:basic', ['jsx:debug', 'browserify:basic']);
|
||||
grunt.registerTask('build:transformer', ['jsx:debug', 'browserify:transformer']);
|
||||
grunt.registerTask('build:min', ['jsx:release', 'browserify:min']);
|
||||
grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);
|
||||
grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
|
||||
grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.pack);
|
||||
|
||||
grunt.registerTask('version-check', versionCheckTask);
|
||||
|
||||
grunt.registerTask('build:basic', ['jsx:normal', 'version-check', 'browserify:basic']);
|
||||
grunt.registerTask('build:addons', ['jsx:normal', 'browserify:addons']);
|
||||
grunt.registerTask('build:transformer', ['jsx:normal', 'browserify:transformer']);
|
||||
grunt.registerTask('build:min', ['jsx:normal', 'version-check', 'browserify:min']);
|
||||
grunt.registerTask('build:addons-min', ['jsx:normal', 'browserify:addonsMin']);
|
||||
grunt.registerTask('build:withCodeCoverageLogging', [
|
||||
'jsx:normal',
|
||||
'version-check',
|
||||
'browserify:withCodeCoverageLogging'
|
||||
]);
|
||||
grunt.registerTask('build:perf', [
|
||||
'jsx:normal',
|
||||
'version-check',
|
||||
'browserify:transformer',
|
||||
'browserify:basic',
|
||||
'browserify:min',
|
||||
'download-previous-version'
|
||||
]);
|
||||
grunt.registerTask('build:test', [
|
||||
'jsx:jasmine',
|
||||
'delete-build-modules',
|
||||
'jsx:test',
|
||||
'populist:jasmine',
|
||||
'version-check',
|
||||
'populist:test'
|
||||
]);
|
||||
grunt.registerTask('build:npm-react', ['version-check', 'jsx:normal', 'npm-react:release']);
|
||||
|
||||
grunt.registerTask('test', ['build:test', 'phantom:run']);
|
||||
grunt.registerTask('webdriver-phantomjs', webdriverPhantomJSTask);
|
||||
|
||||
grunt.registerTask('coverage:parse', require('./grunt/tasks/coverage-parse'));
|
||||
|
||||
grunt.registerTask('test:webdriver:phantomjs', [
|
||||
'connect',
|
||||
'webdriver-phantomjs',
|
||||
'webdriver-jasmine:local'
|
||||
]);
|
||||
|
||||
grunt.registerTask('perf:webdriver:phantomjs', [
|
||||
'connect',
|
||||
'webdriver-phantomjs',
|
||||
'webdriver-perf:local'
|
||||
]);
|
||||
|
||||
grunt.registerTask('test:full', [
|
||||
'build:test',
|
||||
'build:basic',
|
||||
|
||||
'connect',
|
||||
'webdriver-phantomjs',
|
||||
'webdriver-jasmine:local',
|
||||
|
||||
'sauce-tunnel',
|
||||
'webdriver-jasmine:saucelabs_android',
|
||||
'webdriver-jasmine:saucelabs_firefox',
|
||||
'webdriver-jasmine:saucelabs_chrome'
|
||||
]);
|
||||
|
||||
grunt.registerTask('perf:full', [
|
||||
'build:perf',
|
||||
|
||||
'connect',
|
||||
'webdriver-phantomjs',
|
||||
'webdriver-perf:local',
|
||||
|
||||
'sauce-tunnel',
|
||||
'webdriver-perf:saucelabs_firefox',
|
||||
'webdriver-perf:saucelabs_chrome',
|
||||
'webdriver-perf:saucelabs_ie11',
|
||||
'webdriver-perf:saucelabs_ie8',
|
||||
]);
|
||||
|
||||
grunt.registerTask('test:webdriver:saucelabs', [
|
||||
'build:test',
|
||||
'build:basic',
|
||||
|
||||
'connect',
|
||||
'sauce-tunnel',
|
||||
'webdriver-jasmine:saucelabs_' + (process.env.BROWSER_NAME || 'ie8')
|
||||
]);
|
||||
|
||||
grunt.registerTask('test:webdriver:saucelabs:ie', [
|
||||
'build:test',
|
||||
'build:basic',
|
||||
|
||||
'connect',
|
||||
'sauce-tunnel',
|
||||
'webdriver-jasmine:saucelabs_ie8',
|
||||
'webdriver-jasmine:saucelabs_ie9',
|
||||
'webdriver-jasmine:saucelabs_ie10',
|
||||
'webdriver-jasmine:saucelabs_ie11'
|
||||
]);
|
||||
|
||||
grunt.registerTask('test:webdriver:saucelabs:ios', [
|
||||
'build:test',
|
||||
'build:basic',
|
||||
|
||||
'connect',
|
||||
'sauce-tunnel',
|
||||
'webdriver-jasmine:saucelabs_ios6_1',
|
||||
'webdriver-jasmine:saucelabs_ios5_1',
|
||||
'webdriver-jasmine:saucelabs_ios4'
|
||||
]);
|
||||
|
||||
grunt.registerTask('test:coverage', [
|
||||
'build:test',
|
||||
'build:withCodeCoverageLogging',
|
||||
'test:webdriver:phantomjs',
|
||||
'coverage:parse'
|
||||
]);
|
||||
grunt.registerTask('test', ['build:test', 'build:basic', 'test:webdriver:phantomjs']);
|
||||
grunt.registerTask('perf', ['build:perf', 'perf:webdriver:phantomjs']);
|
||||
grunt.registerTask('npm:test', ['build', 'npm:pack']);
|
||||
|
||||
// Optimized build task that does all of our builds. The subtasks will be run
|
||||
// in order so we can take advantage of that and only run jsx:debug once.
|
||||
// in order so we can take advantage of that and only run jsx:normal once.
|
||||
grunt.registerTask('build', [
|
||||
'jsx:debug',
|
||||
'delete-build-modules',
|
||||
'jsx:normal',
|
||||
'version-check',
|
||||
'browserify:basic',
|
||||
'browserify:transformer',
|
||||
'jsx:release',
|
||||
'browserify:addons',
|
||||
'browserify:min',
|
||||
'browserify:addonsMin',
|
||||
'npm-react:release',
|
||||
'npm-react:pack',
|
||||
'npm-react-tools:pack',
|
||||
'copy:react_docs',
|
||||
'compare_size'
|
||||
]);
|
||||
|
||||
32
README.md
32
README.md
@@ -2,21 +2,25 @@
|
||||
|
||||
React is a JavaScript library for building user interfaces.
|
||||
|
||||
* **Declarative:** React uses a declarative paradigm that makes it easier to reason about your application.
|
||||
* **Efficient:** React computes the minimal set of changes necessary to keep your DOM up-to-date.
|
||||
* **Flexible:** React works with the libraries and frameworks that you already know.
|
||||
* **Just the UI:** Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.
|
||||
* **Virtual DOM:** React uses a *virtual DOM* diff implementation for ultra-high performance. It can also render on the server using Node.js — no heavy browser DOM required.
|
||||
* **Data flow:** React implements one-way reactive data flow which reduces boilerplate and is easier to reason about than traditional data binding.
|
||||
|
||||
[Learn how to use React in your own project.](http://facebook.github.io/react/docs/getting-started.html)
|
||||
|
||||
## The `react` npm package has recently changed!
|
||||
|
||||
If you're looking for jeffbski's [React.js](https://github.com/jeffbski/autoflow) project, it's now in `npm` as `autoflow` rather than `react`.
|
||||
|
||||
## Examples
|
||||
|
||||
We have several examples [on the website](http://facebook.github.io/react). Here is the first one to get you started:
|
||||
We have several examples [on the website](http://facebook.github.io/react/). Here is the first one to get you started:
|
||||
|
||||
```js
|
||||
/** @jsx React.DOM */
|
||||
var HelloMessage = React.createClass({
|
||||
render: function() {
|
||||
return <div>{'Hello ' + this.props.name}</div>;
|
||||
return <div>Hello {this.props.name}</div>;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,20 +32,20 @@ React.renderComponent(
|
||||
|
||||
This example will render "Hello John" into a container on the page.
|
||||
|
||||
You'll notice that we used an XML-like syntax; [we call it JSX](http://facebook.github.io/react/docs/syntax.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. A simple transform is included with React that allows converting JSX into native JavaScript for browsers to digest.
|
||||
You'll notice that we used an HTML-like syntax; [we call it JSX](http://facebook.github.io/react/docs/jsx-in-depth.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. A simple transform is included with React that allows converting JSX into native JavaScript for browsers to digest.
|
||||
|
||||
## Installation
|
||||
|
||||
The fastest way to get started is to serve JavaScript from the CDN:
|
||||
The fastest way to get started is to serve JavaScript from the CDN (also available on [CDNJS](http://cdnjs.com/#react)):
|
||||
|
||||
```html
|
||||
<!-- The core React library -->
|
||||
<script src="http://fb.me/react-0.4.0.min.js"></script>
|
||||
<script src="http://fb.me/react-0.8.0.js"></script>
|
||||
<!-- In-browser JSX transformer, remove when pre-compiling JSX. -->
|
||||
<script src="http://fb.me/JSXTransformer-0.4.0.js"></script>
|
||||
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
|
||||
```
|
||||
|
||||
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.4.0.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
|
||||
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.8.0.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
|
||||
|
||||
If you'd like to use [bower](http://bower.io), it's as easy as:
|
||||
|
||||
@@ -51,7 +55,7 @@ bower install --save react
|
||||
|
||||
## Contribute
|
||||
|
||||
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, then keep reading. If you're not interested in helping right now that's ok too :) Any feedback you have about using React would be greatly appreciated.
|
||||
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, then keep reading. If you're not interested in helping right now that's ok too. :) Any feedback you have about using React would be greatly appreciated.
|
||||
|
||||
### Building Your Copy of React
|
||||
|
||||
@@ -81,12 +85,10 @@ At this point, you should now have a `build/` directory populated with everythin
|
||||
We use grunt to automate many tasks. Run `grunt -h` to see a mostly complete listing. The important ones to know:
|
||||
|
||||
```sh
|
||||
# Create test build & run tests with PhantomJS
|
||||
# Build and run tests with PhantomJS
|
||||
grunt test
|
||||
# Lint the core library code with JSHint
|
||||
# Lint the code with JSHint
|
||||
grunt lint
|
||||
# Lint package code
|
||||
grunt lint:package
|
||||
# Wipe out build directory
|
||||
grunt clean
|
||||
```
|
||||
|
||||
65
bin/jsx
65
bin/jsx
@@ -1,55 +1,24 @@
|
||||
#!/usr/bin/env node
|
||||
// -*- mode: js -*-
|
||||
"use strict";
|
||||
|
||||
var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
|
||||
var transform = require('../vendor/fbtransform/lib/transform').transform;
|
||||
var propagate = require("../vendor/constants").propagate;
|
||||
|
||||
require("commoner").resolve(function(id) {
|
||||
var context = this;
|
||||
|
||||
// Note that the result of context.getProvidedP() is cached for the
|
||||
// duration of the build, so it is both consistent and cheap to
|
||||
// evaluate multiple times.
|
||||
return context.getProvidedP().then(function(idToPath) {
|
||||
// If a module declares its own identifier using @providesModule
|
||||
// then that identifier will be a key in the idToPath object.
|
||||
if (idToPath.hasOwnProperty(id)) {
|
||||
return context.readFileP(idToPath[id]);
|
||||
}
|
||||
|
||||
// Otherwise assume the identifier maps directly to a path in the
|
||||
// filesystem.
|
||||
return context.readModuleP(id);
|
||||
});
|
||||
|
||||
}).process(function(id, source) {
|
||||
var context = this;
|
||||
var constants = context.config.constants || {};
|
||||
var visitors = require('../vendor/fbtransform/visitors');
|
||||
var transform = require('jstransform').transform;
|
||||
|
||||
require('commoner').version(
|
||||
require('../package.json').version
|
||||
).resolve(function(id) {
|
||||
return this.readModuleP(id);
|
||||
}).option(
|
||||
'--harmony',
|
||||
'Turns on JS transformations such as ES6 Classes etc.'
|
||||
).process(function(id, source) {
|
||||
// This is where JSX, ES6, etc. desugaring happens.
|
||||
source = transform(visitors.react, source).code;
|
||||
|
||||
// Constant propagation means removing any obviously dead code after
|
||||
// replacing constant expressions with literal (boolean) values.
|
||||
source = propagate(constants, source);
|
||||
|
||||
if (context.config.mocking) {
|
||||
// Make sure there is exactly one newline at the end of the module.
|
||||
source = source.replace(/\s+$/m, "\n");
|
||||
|
||||
return context.getProvidedP().then(function(idToPath) {
|
||||
if (id !== "mock-modules" &&
|
||||
id !== "mocks" &&
|
||||
id !== "test/all" &&
|
||||
idToPath.hasOwnProperty("mock-modules")) {
|
||||
return source + '\nrequire("mock-modules").register(' +
|
||||
JSON.stringify(id) + ', module);\n';
|
||||
}
|
||||
|
||||
return source;
|
||||
});
|
||||
var visitorList;
|
||||
if (this.options.harmony) {
|
||||
visitorList = visitors.getAllVisitors();
|
||||
} else {
|
||||
visitorList = visitors.transformVisitors.react;
|
||||
}
|
||||
|
||||
return source;
|
||||
return transform(visitorList, source).code;
|
||||
});
|
||||
|
||||
58
bin/jsx-internal
Executable file
58
bin/jsx-internal
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env node
|
||||
// -*- mode: js -*-
|
||||
"use strict";
|
||||
|
||||
var getAllVisitors = require('../vendor/fbtransform/visitors').getAllVisitors;
|
||||
var transform = require('jstransform').transform;
|
||||
var propagate = require("../vendor/constants").propagate;
|
||||
|
||||
require("commoner").version(
|
||||
require("../package.json").version
|
||||
).resolve(function(id) {
|
||||
var context = this;
|
||||
|
||||
// Note that the result of context.getProvidedP() is cached for the
|
||||
// duration of the build, so it is both consistent and cheap to
|
||||
// evaluate multiple times.
|
||||
return context.getProvidedP().then(function(idToPath) {
|
||||
// If a module declares its own identifier using @providesModule
|
||||
// then that identifier will be a key in the idToPath object.
|
||||
if (idToPath.hasOwnProperty(id)) {
|
||||
return context.readFileP(idToPath[id]);
|
||||
}
|
||||
|
||||
// Otherwise assume the identifier maps directly to a path in the
|
||||
// filesystem.
|
||||
return context.readModuleP(id);
|
||||
});
|
||||
|
||||
}).process(function(id, source) {
|
||||
var context = this;
|
||||
var constants = context.config.constants || {};
|
||||
|
||||
// This is where JSX, ES6, etc. desugaring happens.
|
||||
source = transform(getAllVisitors(), source).code;
|
||||
|
||||
// Constant propagation means removing any obviously dead code after
|
||||
// replacing constant expressions with literal (boolean) values.
|
||||
source = propagate(constants, source);
|
||||
|
||||
if (context.config.mocking) {
|
||||
// Make sure there is exactly one newline at the end of the module.
|
||||
source = source.replace(/\s+$/m, "\n");
|
||||
|
||||
return context.getProvidedP().then(function(idToPath) {
|
||||
if (id !== "mock-modules" &&
|
||||
id !== "mocks" &&
|
||||
id !== "test/all" &&
|
||||
idToPath.hasOwnProperty("mock-modules")) {
|
||||
return source + '\nrequire("mock-modules").register(' +
|
||||
JSON.stringify(id) + ', module);\n';
|
||||
}
|
||||
|
||||
return source;
|
||||
});
|
||||
}
|
||||
|
||||
return source;
|
||||
});
|
||||
@@ -1,7 +1,9 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake'
|
||||
|
||||
# jekyll, which builds it all
|
||||
gem 'jekyll', '~>1.0'
|
||||
gem 'jekyll', '~>1.3.0'
|
||||
|
||||
# JSON
|
||||
gem 'json'
|
||||
@@ -14,3 +16,6 @@ gem 'rb-fsevent'
|
||||
|
||||
# Redcarpet for Markdown
|
||||
gem 'redcarpet'
|
||||
|
||||
# For markdown header cleanup
|
||||
gem 'sanitize'
|
||||
|
||||
@@ -4,34 +4,47 @@ GEM
|
||||
classifier (1.3.3)
|
||||
fast-stemmer (>= 1.0.0)
|
||||
colorator (0.1)
|
||||
commander (4.1.3)
|
||||
commander (4.1.5)
|
||||
highline (~> 1.6.11)
|
||||
directory_watcher (1.4.1)
|
||||
fast-stemmer (1.0.2)
|
||||
highline (1.6.19)
|
||||
jekyll (1.0.2)
|
||||
ffi (1.9.3)
|
||||
highline (1.6.20)
|
||||
jekyll (1.3.0)
|
||||
classifier (~> 1.3)
|
||||
colorator (~> 0.1)
|
||||
commander (~> 4.1.3)
|
||||
directory_watcher (~> 1.4.1)
|
||||
kramdown (~> 1.0.2)
|
||||
liquid (~> 2.3)
|
||||
maruku (~> 0.5)
|
||||
liquid (~> 2.5.2)
|
||||
listen (~> 1.3)
|
||||
maruku (~> 0.6.0)
|
||||
pygments.rb (~> 0.5.0)
|
||||
safe_yaml (~> 0.7.0)
|
||||
json (1.8.0)
|
||||
kramdown (1.0.2)
|
||||
liquid (2.5.0)
|
||||
redcarpet (~> 2.3.0)
|
||||
safe_yaml (~> 0.9.7)
|
||||
json (1.8.1)
|
||||
liquid (2.5.4)
|
||||
listen (1.3.1)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
rb-kqueue (>= 0.2)
|
||||
maruku (0.6.1)
|
||||
syntax (>= 1.0.0)
|
||||
mini_portile (0.5.2)
|
||||
nokogiri (1.6.0)
|
||||
mini_portile (~> 0.5.0)
|
||||
posix-spawn (0.3.6)
|
||||
pygments.rb (0.5.0)
|
||||
pygments.rb (0.5.4)
|
||||
posix-spawn (~> 0.3.6)
|
||||
yajl-ruby (~> 1.1.0)
|
||||
rake (10.1.0)
|
||||
rb-fsevent (0.9.3)
|
||||
redcarpet (2.2.2)
|
||||
safe_yaml (0.7.1)
|
||||
sass (3.2.9)
|
||||
rb-inotify (0.9.2)
|
||||
ffi (>= 0.5.0)
|
||||
rb-kqueue (0.2.0)
|
||||
ffi (>= 0.5.0)
|
||||
redcarpet (2.3.0)
|
||||
safe_yaml (0.9.7)
|
||||
sanitize (2.0.6)
|
||||
nokogiri (>= 1.4.4)
|
||||
sass (3.2.12)
|
||||
syntax (1.0.0)
|
||||
yajl-ruby (1.1.0)
|
||||
|
||||
@@ -39,8 +52,10 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
jekyll (~> 1.0)
|
||||
jekyll (~> 1.3.0)
|
||||
json
|
||||
rake
|
||||
rb-fsevent
|
||||
redcarpet
|
||||
sanitize
|
||||
sass
|
||||
|
||||
@@ -21,6 +21,7 @@ Once you have RubyGems and installed Bundler (via `gem install bundler`), use it
|
||||
```sh
|
||||
$ cd react/docs
|
||||
$ bundle install # Might need sudo.
|
||||
$ npm install # Might need sudo.
|
||||
```
|
||||
|
||||
### Instructions
|
||||
|
||||
@@ -13,7 +13,7 @@ task :js do
|
||||
end
|
||||
|
||||
desc "watch css & js"
|
||||
task :watch => [:update_version] do
|
||||
task :watch do
|
||||
Process.spawn "sass --style=compressed --watch _css/react.scss:css/react.css"
|
||||
Process.spawn "../bin/jsx --watch _js js"
|
||||
Process.waitall
|
||||
@@ -30,8 +30,8 @@ task :update_version do
|
||||
end
|
||||
|
||||
desc "build into ../../react-gh-pages"
|
||||
task :release => [:default] do
|
||||
task :release => [:update_version, :default] do
|
||||
system "jekyll build -d ../../react-gh-pages"
|
||||
end
|
||||
|
||||
task :default => [:update_version, :css, :js]
|
||||
task :default => [:css, :js]
|
||||
|
||||
@@ -13,41 +13,9 @@ redcarpet:
|
||||
pygments: true
|
||||
name: React
|
||||
markdown: redcarpet
|
||||
react_version: 0.4.1
|
||||
react_version: 0.9.0
|
||||
description: A JavaScript library for building user interfaces
|
||||
relative_permalinks: true
|
||||
nav_docs_sections:
|
||||
- title: Quick Start
|
||||
items:
|
||||
- id: getting-started
|
||||
title: Getting Started
|
||||
- id: tutorial
|
||||
title: Tutorial
|
||||
- title: Guides
|
||||
items:
|
||||
- id: why-react
|
||||
title: Why React?
|
||||
- id: displaying-data
|
||||
title: Displaying Data
|
||||
subitems:
|
||||
- id: jsx-in-depth
|
||||
title: JSX in Depth
|
||||
- id: jsx-gotchas
|
||||
title: JSX Gotchas
|
||||
- id: interactivity-and-dynamic-uis
|
||||
title: Interactivity and Dynamic UIs
|
||||
- id: multiple-components
|
||||
title: Multiple Components
|
||||
- id: reusable-components
|
||||
title: Reusable Components
|
||||
- id: forms
|
||||
title: Forms
|
||||
- id: working-with-the-browser
|
||||
title: Working With the Browser
|
||||
subitems:
|
||||
- id: more-about-refs
|
||||
title: More About Refs
|
||||
- id: tooling-integration
|
||||
title: Tooling integration
|
||||
- id: reference
|
||||
title: Reference
|
||||
paginate: 5
|
||||
paginate_path: /blog/page:num/
|
||||
timezone: America/Los_Angeles
|
||||
|
||||
@@ -15,6 +15,7 @@ $contentPadding: 20px;
|
||||
$columnWidth: 280px;
|
||||
$columnGutter: 40px;
|
||||
$twoColumnWidth: 2 * $columnWidth + $columnGutter;
|
||||
$navHeight: 50px;
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +43,7 @@ html {
|
||||
|
||||
|
||||
.container {
|
||||
padding-top: 50px;
|
||||
padding-top: $navHeight;
|
||||
min-width: $contentWidth + (2 * $contentPadding);
|
||||
}
|
||||
|
||||
@@ -73,6 +74,23 @@ li {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
// Make header navigation linkable and on the screen. Used in documentation and
|
||||
// blog posts.
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
.anchor {
|
||||
margin-top: -$navHeight;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
&:hover .hash-link {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
.hash-link {
|
||||
color: $mediumTextColor;
|
||||
display: none;
|
||||
}
|
||||
|
||||
// Main Nav
|
||||
|
||||
.nav-main {
|
||||
@@ -81,7 +99,7 @@ li {
|
||||
color: $lightTextColor;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
height: 50px;
|
||||
height: $navHeight;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, .5);
|
||||
width: 100%;
|
||||
z-index: 100;
|
||||
@@ -103,9 +121,9 @@ li {
|
||||
padding: 0 8px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
line-height: 50px;
|
||||
line-height: $navHeight;
|
||||
display: inline-block;
|
||||
height: 50px;
|
||||
height: $navHeight;
|
||||
color: $mediumTextColor;
|
||||
|
||||
&:hover {
|
||||
@@ -123,7 +141,7 @@ li {
|
||||
.nav-home {
|
||||
color: #00d8ff;
|
||||
font-size: 24px;
|
||||
line-height: 50px;
|
||||
line-height: $navHeight;
|
||||
}
|
||||
|
||||
.nav-logo {
|
||||
@@ -199,8 +217,7 @@ li {
|
||||
font-size: 14px;
|
||||
// position: fixed;
|
||||
float: left;
|
||||
top: 100px;
|
||||
width: 180px;
|
||||
width: 210px;
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
@@ -248,6 +265,12 @@ li {
|
||||
|
||||
}
|
||||
|
||||
.nav-blog {
|
||||
li {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
// Home Page specifics
|
||||
|
||||
.home-section {
|
||||
@@ -267,7 +290,7 @@ li {
|
||||
|
||||
.marketing-col {
|
||||
float: left;
|
||||
margin-right: 40px;
|
||||
margin-left: 40px;
|
||||
width: $columnWidth;
|
||||
|
||||
h3 {
|
||||
@@ -281,18 +304,18 @@ li {
|
||||
}
|
||||
}
|
||||
|
||||
.marketing-col:last-child {
|
||||
margin-right: 0;
|
||||
.marketing-col:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
#examples h3, .home-presentation h3 {
|
||||
color: $darkColor;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
#examples {
|
||||
h3 {
|
||||
color: $darkColor;
|
||||
font-size: 24px;
|
||||
font-weight: normal;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 25px 0;
|
||||
max-width: $twoColumnWidth;
|
||||
@@ -364,6 +387,8 @@ section.black content {
|
||||
*/
|
||||
|
||||
.blogContent {
|
||||
@include clearfix;
|
||||
|
||||
padding-top: 20px;
|
||||
|
||||
blockquote {
|
||||
@@ -386,6 +411,7 @@ section.black content {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
|
||||
// H2s form documentation topic dividers. Extra space helps.
|
||||
h2 {
|
||||
margin-top: 30px;
|
||||
@@ -393,7 +419,7 @@ section.black content {
|
||||
|
||||
padding-top: 20px;
|
||||
|
||||
// Make a notice box out of blockquotes in the documetation:
|
||||
// Make a notice box out of blockquotes in the documentation:
|
||||
blockquote {
|
||||
padding: 15px 30px 15px 15px;
|
||||
margin: 20px 0;
|
||||
@@ -402,7 +428,7 @@ section.black content {
|
||||
h4 {
|
||||
margin-top: 0;
|
||||
}
|
||||
p:last-child {
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
// Treat first child as the title - promote to H4.
|
||||
@@ -433,13 +459,19 @@ section.black content {
|
||||
}
|
||||
|
||||
.playgroundPreview {
|
||||
padding: 14px;
|
||||
padding: 0;
|
||||
width: 600px;
|
||||
|
||||
pre {
|
||||
@include code-typography;
|
||||
}
|
||||
}
|
||||
|
||||
.playgroundError {
|
||||
// The compiler view kills padding in order to render the CodeMirror code
|
||||
// more nicely. For the error view, put a padding back
|
||||
padding: 15px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Button */
|
||||
@@ -534,7 +566,7 @@ figure {
|
||||
margin-top: 60px;
|
||||
}
|
||||
|
||||
/* Code Mirror */
|
||||
/* CodeMirror */
|
||||
|
||||
div.CodeMirror pre, div.CodeMirror-linenumber, code {
|
||||
@include code-typography;
|
||||
@@ -548,6 +580,11 @@ div.CodeMirror-linenumber:after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* hide the cursor. Mostly used when code's in plain JS */
|
||||
.CodeMirror-readonly div.CodeMirror-cursor {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
small code,
|
||||
li code,
|
||||
p code {
|
||||
@@ -564,23 +601,28 @@ p code {
|
||||
@include clearfix;
|
||||
}
|
||||
|
||||
.playground::before {
|
||||
.playground-tab {
|
||||
border-bottom: none !important;
|
||||
border-radius: 3px 3px 0 0;
|
||||
padding: 3px 7px;
|
||||
padding: 6px 8px;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #c2c0bc;
|
||||
background-color: #f1ede4;
|
||||
content: 'Live editor';
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.playground::before,
|
||||
.playgroundCode,
|
||||
.playground-tab,
|
||||
.playgroundPreview {
|
||||
border: 1px solid rgba(16,16,16,0.1);
|
||||
}
|
||||
|
||||
.playground-tab-active {
|
||||
color: $darkestColor;
|
||||
}
|
||||
|
||||
.playgroundCode {
|
||||
border-radius: 0 3px 3px 3px;
|
||||
float: left;
|
||||
@@ -596,6 +638,11 @@ p code {
|
||||
width: $columnWidth;
|
||||
}
|
||||
|
||||
.playgroundError {
|
||||
color: darken($primary, 5%);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.MarkdownEditor textarea {
|
||||
width: 100%;
|
||||
height: 100px
|
||||
@@ -610,7 +657,7 @@ p code {
|
||||
padding-left: 9px;
|
||||
}
|
||||
|
||||
/* Codemirror doesn't support <jsx> syntax. Instead of highlighting it
|
||||
/* CodeMirror doesn't support <jsx> syntax. Instead of highlighting it
|
||||
as error, just ignore it */
|
||||
.highlight .javascript .err {
|
||||
background-color: transparent;
|
||||
@@ -685,3 +732,36 @@ p code {
|
||||
.post {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
margin-bottom: 30px;
|
||||
|
||||
/* Trick to get the wrapper to expand to fit floating elements */
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
.next {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
||||
// Twitter embeds. Need to !important because they inline margin on the iframe.
|
||||
div[data-twttr-id] iframe {
|
||||
margin: 10px auto !important;
|
||||
}
|
||||
|
||||
/* Acknowledgements */
|
||||
|
||||
.three-column {
|
||||
@include clearfix;
|
||||
}
|
||||
|
||||
.three-column > ul {
|
||||
float: left;
|
||||
margin-left: 30px;
|
||||
width: 190px;
|
||||
}
|
||||
|
||||
.three-column > ul:first-child {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
73
docs/_data/nav_docs.yml
Normal file
73
docs/_data/nav_docs.yml
Normal file
@@ -0,0 +1,73 @@
|
||||
- title: Quick Start
|
||||
items:
|
||||
- id: getting-started
|
||||
title: Getting Started
|
||||
- id: tutorial
|
||||
title: Tutorial
|
||||
- id: thinking-in-react
|
||||
title: Thinking in React
|
||||
- title: Community Resources
|
||||
items:
|
||||
- id: videos
|
||||
title: Videos
|
||||
- id: complementary-tools
|
||||
title: Complementary Tools
|
||||
- id: examples
|
||||
title: Examples
|
||||
- title: Guides
|
||||
items:
|
||||
- id: why-react
|
||||
title: Why React?
|
||||
- id: displaying-data
|
||||
title: Displaying Data
|
||||
subitems:
|
||||
- id: jsx-in-depth
|
||||
title: JSX in Depth
|
||||
- id: jsx-gotchas
|
||||
title: JSX Gotchas
|
||||
- id: interactivity-and-dynamic-uis
|
||||
title: Interactivity and Dynamic UIs
|
||||
- id: multiple-components
|
||||
title: Multiple Components
|
||||
- id: reusable-components
|
||||
title: Reusable Components
|
||||
- id: forms
|
||||
title: Forms
|
||||
- id: working-with-the-browser
|
||||
title: Working With the Browser
|
||||
subitems:
|
||||
- id: more-about-refs
|
||||
title: More About Refs
|
||||
- id: tooling-integration
|
||||
title: Tooling Integration
|
||||
- id: addons
|
||||
title: Add-Ons
|
||||
subitems:
|
||||
- id: animation
|
||||
title: Animation
|
||||
- id: two-way-binding-helpers
|
||||
title: Two-Way Binding Helpers
|
||||
- id: class-name-manipulation
|
||||
title: Class Name Manipulation
|
||||
- id: test-utils
|
||||
title: Test Utilities
|
||||
- id: clone-with-props
|
||||
title: Cloning Components
|
||||
- title: Reference
|
||||
items:
|
||||
- id: top-level-api
|
||||
title: Top-Level API
|
||||
- id: component-api
|
||||
title: Component API
|
||||
- id: component-specs
|
||||
title: Component Specs and Lifecycle
|
||||
- id: tags-and-attributes
|
||||
title: Supported Tags and Attributes
|
||||
- id: events
|
||||
title: Event System
|
||||
- id: dom-differences
|
||||
title: DOM Differences
|
||||
- id: special-non-dom-attributes
|
||||
title: Special Non-DOM Attributes
|
||||
- id: reconciliation
|
||||
title: Reconciliation
|
||||
32
docs/_data/nav_tips.yml
Normal file
32
docs/_data/nav_tips.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
- title: Tips
|
||||
items:
|
||||
- id: introduction
|
||||
title: Introduction
|
||||
- id: inline-styles
|
||||
title: Inline Styles
|
||||
- id: if-else-in-JSX
|
||||
title: If-Else in JSX
|
||||
- id: self-closing-tag
|
||||
title: Self-Closing Tag
|
||||
- id: maximum-number-of-jsx-root-nodes
|
||||
title: Maximum Number of JSX Root Nodes
|
||||
- id: style-props-value-px
|
||||
title: Shorthand for Specifying Pixel Values in style props
|
||||
- id: children-props-type
|
||||
title: Type of the Children props
|
||||
- id: controlled-input-null-value
|
||||
title: Value of null for Controlled Input
|
||||
- id: componentWillReceiveProps-not-triggered-after-mounting
|
||||
title: componentWillReceiveProps Not Triggered After Mounting
|
||||
- id: props-in-getInitialState-as-anti-pattern
|
||||
title: Props in getInitialState Is an Anti-Pattern
|
||||
- id: dom-event-listeners
|
||||
title: DOM Event Listeners in a Component
|
||||
- id: initial-ajax
|
||||
title: Load Initial Data via AJAX
|
||||
- id: false-in-jsx
|
||||
title: False in JSX
|
||||
- id: communicate-between-components
|
||||
title: Communicate Between Components
|
||||
- id: expose-component-functions
|
||||
title: Expose Component Functions
|
||||
@@ -1,10 +1,11 @@
|
||||
<div class="nav-docs">
|
||||
<div class="nav-docs nav-blog">
|
||||
<div class="nav-docs-section">
|
||||
<h3>Recent posts</h3>
|
||||
<ul>
|
||||
{% for post in site.posts %}
|
||||
<li><a href="/react{{ post.url }}"{% if page.title == post.title %} class="active"{% endif %}>{{ post.title }}</a></li>
|
||||
{% endfor %}
|
||||
{% for post in site.posts limit:10 %}
|
||||
<li><a href="/react{{ post.url }}"{% if page.title == post.title %} class="active"{% endif %}>{{ post.title }}</a></li>
|
||||
{% endfor %}
|
||||
<li><a href="/react/blog/all.html">All posts ...</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<div class="nav-docs">
|
||||
{% for section in site.nav_docs_sections %}
|
||||
<!-- Docs Nav -->
|
||||
{% for section in site.data.nav_docs %}
|
||||
<div class="nav-docs-section">
|
||||
<h3>{{ section.title }}</h3>
|
||||
<ul>
|
||||
@@ -24,4 +25,18 @@
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!-- Tips Nav -->
|
||||
{% for section in site.data.nav_tips %}
|
||||
<div class="nav-docs-section">
|
||||
<h3>{{ section.title }}</h3>
|
||||
<ul>
|
||||
{% for item in section.items %}
|
||||
<li>
|
||||
<a href="/react/tips/{{ item.id }}.html"{% if page.id == item.id %} class="active"{% endif %}>{{ item.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
2
docs/_js/es5-sham.min.js
vendored
Normal file
2
docs/_js/es5-sham.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
docs/_js/es5-shim.min.js
vendored
Normal file
2
docs/_js/es5-shim.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@ var HELLO_COMPONENT = "\
|
||||
/** @jsx React.DOM */\n\
|
||||
var HelloMessage = React.createClass({\n\
|
||||
render: function() {\n\
|
||||
return <div>{'Hello ' + this.props.name}</div>;\n\
|
||||
return <div>Hello {this.props.name}</div>;\n\
|
||||
}\n\
|
||||
});\n\
|
||||
\n\
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
var TIMER_COMPONENT = "\
|
||||
/** @jsx React.DOM */\n\
|
||||
var Timer = React.createClass({\n\
|
||||
getInitialState: function() {\n\
|
||||
return {secondsElapsed: 0};\n\
|
||||
@@ -17,13 +18,13 @@ var Timer = React.createClass({\n\
|
||||
clearInterval(this.interval);\n\
|
||||
},\n\
|
||||
render: function() {\n\
|
||||
return React.DOM.div({},\n\
|
||||
'Seconds Elapsed: ' + this.state.secondsElapsed\n\
|
||||
return (\n\
|
||||
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>\n\
|
||||
);\n\
|
||||
}\n\
|
||||
});\n\
|
||||
\n\
|
||||
React.renderComponent(Timer({}), mountNode);\
|
||||
React.renderComponent(<Timer />, mountNode);\
|
||||
";
|
||||
|
||||
React.renderComponent(
|
||||
|
||||
482
docs/_js/html-jsx-lib.js
Normal file
482
docs/_js/html-jsx-lib.js
Normal file
@@ -0,0 +1,482 @@
|
||||
/**
|
||||
* Copyright 2013-2014 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a very simple HTML to JSX converter. It turns out that browsers
|
||||
* have good HTML parsers (who would have thought?) so we utilise this by
|
||||
* inserting the HTML into a temporary DOM node, and then do a breadth-first
|
||||
* traversal of the resulting DOM tree.
|
||||
*/
|
||||
;(function(global) {
|
||||
'use strict';
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeType
|
||||
var NODE_TYPE = {
|
||||
ELEMENT: 1,
|
||||
TEXT: 3,
|
||||
COMMENT: 8
|
||||
};
|
||||
var ATTRIBUTE_MAPPING = {
|
||||
'for': 'htmlFor',
|
||||
'class': 'className'
|
||||
};
|
||||
|
||||
/**
|
||||
* Repeats a string a certain number of times.
|
||||
* Also: the future is bright and consists of native string repetition:
|
||||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
|
||||
*
|
||||
* @param {string} string String to repeat
|
||||
* @param {number} times Number of times to repeat string. Integer.
|
||||
* @see http://jsperf.com/string-repeater/2
|
||||
*/
|
||||
function repeatString(string, times) {
|
||||
if (times === 1) {
|
||||
return string;
|
||||
}
|
||||
if (times < 0) { throw new Error(); }
|
||||
var repeated = '';
|
||||
while (times) {
|
||||
if (times & 1) {
|
||||
repeated += string;
|
||||
}
|
||||
if (times >>= 1) {
|
||||
string += string;
|
||||
}
|
||||
}
|
||||
return repeated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the string ends with the specified substring.
|
||||
*
|
||||
* @param {string} haystack String to search in
|
||||
* @param {string} needle String to search for
|
||||
* @return {boolean}
|
||||
*/
|
||||
function endsWith(haystack, needle) {
|
||||
return haystack.slice(-needle.length) === needle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the specified substring off the string. If the string does not end
|
||||
* with the specified substring, this is a no-op.
|
||||
*
|
||||
* @param {string} haystack String to search in
|
||||
* @param {string} needle String to search for
|
||||
* @return {string}
|
||||
*/
|
||||
function trimEnd(haystack, needle) {
|
||||
return endsWith(haystack, needle)
|
||||
? haystack.slice(0, -needle.length)
|
||||
: haystack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a hyphenated string to camelCase.
|
||||
*/
|
||||
function hyphenToCamelCase(string) {
|
||||
return string.replace(/-(.)/g, function(match, chr) {
|
||||
return chr.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specified string consists entirely of whitespace.
|
||||
*/
|
||||
function isEmpty(string) {
|
||||
return !/[^\s]/.test(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the specified string consists entirely of numeric characters.
|
||||
*/
|
||||
function isNumeric(input) {
|
||||
return input !== undefined
|
||||
&& input !== null
|
||||
&& (typeof input === 'number' || parseInt(input, 10) == input);
|
||||
}
|
||||
|
||||
var HTMLtoJSX = function(config) {
|
||||
this.config = config || {};
|
||||
|
||||
if (this.config.createClass === undefined) {
|
||||
this.config.createClass = true;
|
||||
}
|
||||
if (!this.config.indent) {
|
||||
this.config.indent = ' ';
|
||||
}
|
||||
if (!this.config.outputClassName) {
|
||||
this.config.outputClassName = 'NewComponent';
|
||||
}
|
||||
};
|
||||
HTMLtoJSX.prototype = {
|
||||
/**
|
||||
* Reset the internal state of the converter
|
||||
*/
|
||||
reset: function() {
|
||||
this.output = '';
|
||||
this.level = 0;
|
||||
},
|
||||
/**
|
||||
* Main entry point to the converter. Given the specified HTML, returns a
|
||||
* JSX object representing it.
|
||||
* @param {string} html HTML to convert
|
||||
* @return {string} JSX
|
||||
*/
|
||||
convert: function(html) {
|
||||
this.reset();
|
||||
|
||||
// It turns out browsers have good HTML parsers (imagine that).
|
||||
// Let's take advantage of it.
|
||||
var containerEl = document.createElement('div');
|
||||
containerEl.innerHTML = '\n' + this._cleanInput(html) + '\n';
|
||||
|
||||
if (this.config.createClass) {
|
||||
if (this.config.outputClassName) {
|
||||
this.output = 'var ' + this.config.outputClassName + ' = React.createClass({\n';
|
||||
} else {
|
||||
this.output = 'React.createClass({\n';
|
||||
}
|
||||
this.output += this.config.indent + 'render: function() {' + "\n";
|
||||
this.output += this.config.indent + this.config.indent + 'return (\n';
|
||||
}
|
||||
|
||||
if (this._onlyOneTopLevel(containerEl)) {
|
||||
// Only one top-level element, the component can return it directly
|
||||
// No need to actually visit the container element
|
||||
this._traverse(containerEl);
|
||||
} else {
|
||||
// More than one top-level element, need to wrap the whole thing in a
|
||||
// container.
|
||||
this.output += this.config.indent + this.config.indent + this.config.indent;
|
||||
this.level++;
|
||||
this._visit(containerEl);
|
||||
}
|
||||
this.output = this.output.trim() + '\n';
|
||||
if (this.config.createClass) {
|
||||
this.output += this.config.indent + this.config.indent + ');\n';
|
||||
this.output += this.config.indent + '}\n';
|
||||
this.output += '});';
|
||||
}
|
||||
return this.output;
|
||||
},
|
||||
|
||||
/**
|
||||
* Cleans up the specified HTML so it's in a format acceptable for
|
||||
* converting.
|
||||
*
|
||||
* @param {string} html HTML to clean
|
||||
* @return {string} Cleaned HTML
|
||||
*/
|
||||
_cleanInput: function(html) {
|
||||
// Remove unnecessary whitespace
|
||||
html = html.trim();
|
||||
// Ugly method to strip script tags. They can wreak havoc on the DOM nodes
|
||||
// so let's not even put them in the DOM.
|
||||
html = html.replace(/<script(.*?)<\/script>/g, '');
|
||||
return html;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines if there's only one top-level node in the DOM tree. That is,
|
||||
* all the HTML is wrapped by a single HTML tag.
|
||||
*
|
||||
* @param {DOMElement} containerEl Container element
|
||||
* @return {boolean}
|
||||
*/
|
||||
_onlyOneTopLevel: function(containerEl) {
|
||||
// Only a single child element
|
||||
if (
|
||||
containerEl.childNodes.length === 1
|
||||
&& containerEl.childNodes[0].nodeType === NODE_TYPE.ELEMENT
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
// Only one element, and all other children are whitespace
|
||||
var foundElement = false;
|
||||
for (var i = 0, count = containerEl.childNodes.length; i < count; i++) {
|
||||
var child = containerEl.childNodes[i];
|
||||
if (child.nodeType === NODE_TYPE.ELEMENT) {
|
||||
if (foundElement) {
|
||||
// Encountered an element after already encountering another one
|
||||
// Therefore, more than one element at root level
|
||||
return false;
|
||||
} else {
|
||||
foundElement = true;
|
||||
}
|
||||
} else if (child.nodeType === NODE_TYPE.TEXT && !isEmpty(child.textContent)) {
|
||||
// Contains text content
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a newline followed by the correct indentation for the current
|
||||
* nesting level
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
_getIndentedNewline: function() {
|
||||
return '\n' + repeatString(this.config.indent, this.level + 2);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles processing the specified node
|
||||
*
|
||||
* @param {Node} node
|
||||
*/
|
||||
_visit: function(node) {
|
||||
this._beginVisit(node);
|
||||
this._traverse(node);
|
||||
this._endVisit(node);
|
||||
},
|
||||
|
||||
/**
|
||||
* Traverses all the children of the specified node
|
||||
*
|
||||
* @param {Node} node
|
||||
*/
|
||||
_traverse: function(node) {
|
||||
this.level++;
|
||||
for (var i = 0, count = node.childNodes.length; i < count; i++) {
|
||||
this._visit(node.childNodes[i]);
|
||||
}
|
||||
this.level--;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle pre-visit behaviour for the specified node.
|
||||
*
|
||||
* @param {Node} node
|
||||
*/
|
||||
_beginVisit: function(node) {
|
||||
switch (node.nodeType) {
|
||||
case NODE_TYPE.ELEMENT:
|
||||
this._beginVisitElement(node);
|
||||
break;
|
||||
|
||||
case NODE_TYPE.TEXT:
|
||||
this._visitText(node);
|
||||
break;
|
||||
|
||||
case NODE_TYPE.COMMENT:
|
||||
this._visitComment(node);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn('Unrecognised node type: ' + node.nodeType);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles post-visit behaviour for the specified node.
|
||||
*
|
||||
* @param {Node} node
|
||||
*/
|
||||
_endVisit: function(node) {
|
||||
switch (node.nodeType) {
|
||||
case NODE_TYPE.ELEMENT:
|
||||
this._endVisitElement(node);
|
||||
break;
|
||||
// No ending tags required for these types
|
||||
case NODE_TYPE.TEXT:
|
||||
case NODE_TYPE.COMMENT:
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles pre-visit behaviour for the specified element node
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
*/
|
||||
_beginVisitElement: function(node) {
|
||||
var tagName = node.tagName.toLowerCase();
|
||||
var attributes = [];
|
||||
for (var i = 0, count = node.attributes.length; i < count; i++) {
|
||||
attributes.push(this._getElementAttribute(node, node.attributes[i]));
|
||||
}
|
||||
|
||||
this.output += '<' + tagName;
|
||||
if (attributes.length > 0) {
|
||||
this.output += ' ' + attributes.join(' ');
|
||||
}
|
||||
if (node.firstChild) {
|
||||
this.output += '>';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles post-visit behaviour for the specified element node
|
||||
*
|
||||
* @param {Node} node
|
||||
*/
|
||||
_endVisitElement: function(node) {
|
||||
// De-indent a bit
|
||||
// TODO: It's inefficient to do it this way :/
|
||||
this.output = trimEnd(this.output, this.config.indent);
|
||||
if (node.firstChild) {
|
||||
this.output += '</' + node.tagName.toLowerCase() + '>';
|
||||
} else {
|
||||
this.output += ' />';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles processing of the specified text node
|
||||
*
|
||||
* @param {TextNode} node
|
||||
*/
|
||||
_visitText: function(node) {
|
||||
var text = node.textContent;
|
||||
// If there's a newline in the text, adjust the indent level
|
||||
if (text.indexOf('\n') > -1) {
|
||||
text = node.textContent.replace(/\n\s*/g, this._getIndentedNewline());
|
||||
}
|
||||
this.output += text;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles processing of the specified text node
|
||||
*
|
||||
* @param {Text} node
|
||||
*/
|
||||
_visitComment: function(node) {
|
||||
// Do not render the comment
|
||||
// Since we remove comments, we also need to remove the next line break so we
|
||||
// don't end up with extra whitespace after every comment
|
||||
//if (node.nextSibling && node.nextSibling.nodeType === NODE_TYPE.TEXT) {
|
||||
// node.nextSibling.textContent = node.nextSibling.textContent.replace(/\n\s*/, '');
|
||||
//}
|
||||
this.output += '{/*' + node.textContent.replace('*/', '* /') + '*/}';
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a JSX formatted version of the specified attribute from the node
|
||||
*
|
||||
* @param {DOMElement} node
|
||||
* @param {object} attribute
|
||||
* @return {string}
|
||||
*/
|
||||
_getElementAttribute: function(node, attribute) {
|
||||
switch (attribute.name) {
|
||||
case 'style':
|
||||
return this._getStyleAttribute(attribute.value);
|
||||
default:
|
||||
var name = ATTRIBUTE_MAPPING[attribute.name] || attribute.name;
|
||||
var result = name + '=';
|
||||
// Numeric values should be output as {123} not "123"
|
||||
if (isNumeric(attribute.value)) {
|
||||
result += '{' + attribute.value + '}';
|
||||
} else {
|
||||
result += '"' + attribute.value.replace('"', '"') + '"';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets a JSX formatted version of the specified element styles
|
||||
*
|
||||
* @param {string} styles
|
||||
* @return {string}
|
||||
*/
|
||||
_getStyleAttribute: function(styles) {
|
||||
var jsxStyles = new StyleParser(styles).toJSXString();
|
||||
return 'style={{' + jsxStyles + '}}';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles parsing of inline styles
|
||||
*
|
||||
* @param {string} rawStyle Raw style attribute
|
||||
* @constructor
|
||||
*/
|
||||
var StyleParser = function(rawStyle) {
|
||||
this.parse(rawStyle);
|
||||
};
|
||||
StyleParser.prototype = {
|
||||
/**
|
||||
* Parse the specified inline style attribute value
|
||||
* @param {string} rawStyle Raw style attribute
|
||||
*/
|
||||
parse: function(rawStyle) {
|
||||
this.styles = {};
|
||||
rawStyle.split(';').forEach(function(style) {
|
||||
style = style.trim();
|
||||
var firstColon = style.indexOf(':');
|
||||
var key = style.substr(0, firstColon);
|
||||
var value = style.substr(firstColon + 1).trim();
|
||||
if (key !== '') {
|
||||
this.styles[key] = value;
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert the style information represented by this parser into a JSX
|
||||
* string
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
toJSXString: function() {
|
||||
var output = [];
|
||||
for (var key in this.styles) {
|
||||
if (!this.styles.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
output.push(this.toJSXKey(key) + ': ' + this.toJSXValue(this.styles[key]));
|
||||
}
|
||||
return output.join(', ');
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert the CSS style key to a JSX style key
|
||||
*
|
||||
* @param {string} key CSS style key
|
||||
* @return {string} JSX style key
|
||||
*/
|
||||
toJSXKey: function(key) {
|
||||
return hyphenToCamelCase(key);
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert the CSS style value to a JSX style value
|
||||
*
|
||||
* @param {string} value CSS style value
|
||||
* @return {string} JSX style value
|
||||
*/
|
||||
toJSXValue: function(value) {
|
||||
if (isNumeric(value)) {
|
||||
// If numeric, no quotes
|
||||
return value;
|
||||
} else if (endsWith(value, 'px')) {
|
||||
// "500px" -> 500
|
||||
return trimEnd(value, 'px');
|
||||
} else {
|
||||
// Proably a string, wrap it in quotes
|
||||
return '\'' + value.replace(/'/g, '"') + '\'';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Expose public API
|
||||
global.HTMLtoJSX = HTMLtoJSX;
|
||||
}(window));
|
||||
89
docs/_js/html-jsx.js
Normal file
89
docs/_js/html-jsx.js
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Copyright 2013-2014 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @jsx React.DOM
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a web interface for the HTML to JSX converter contained in
|
||||
* `html-jsx-lib.js`.
|
||||
*/
|
||||
;(function() {
|
||||
|
||||
var HELLO_COMPONENT = "\
|
||||
<!-- Hello world -->\n\
|
||||
<div class=\"awesome\" style=\"border: 1px solid red\">\n\
|
||||
<label for=\"name\">Enter your name: </label>\n\
|
||||
<input type=\"text\" id=\"name\" />\n\
|
||||
</div>\n\
|
||||
<p>Enter your HTML here</p>\
|
||||
";
|
||||
|
||||
var HTMLtoJSXComponent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
outputClassName: 'NewComponent',
|
||||
createClass: true
|
||||
};
|
||||
},
|
||||
onReactClassNameChange: function(evt) {
|
||||
this.setState({ outputClassName: evt.target.value });
|
||||
},
|
||||
onCreateClassChange: function(evt) {
|
||||
this.setState({ createClass: evt.target.checked });
|
||||
},
|
||||
setInput: function(input) {
|
||||
this.setState({ input: input });
|
||||
this.convertToJsx();
|
||||
},
|
||||
convertToJSX: function(input) {
|
||||
var converter = new HTMLtoJSX({
|
||||
outputClassName: this.state.outputClassName,
|
||||
createClass: this.state.createClass
|
||||
});
|
||||
return converter.convert(input);
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<div id="options">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={this.state.createClass}
|
||||
onChange={this.onCreateClassChange} />
|
||||
Create class
|
||||
</label>
|
||||
<label style={{display: this.state.createClass ? '' : 'none'}}>
|
||||
·
|
||||
Class name:
|
||||
<input
|
||||
type="text"
|
||||
value={this.state.outputClassName}
|
||||
onChange={this.onReactClassNameChange} />
|
||||
</label>
|
||||
</div>
|
||||
<ReactPlayground
|
||||
codeText={HELLO_COMPONENT}
|
||||
renderCode={true}
|
||||
transformer={this.convertToJSX}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
React.renderComponent(<HTMLtoJSXComponent />, document.getElementById('jsxCompiler'));
|
||||
}());
|
||||
8
docs/_js/html5shiv.min.js
vendored
Normal file
8
docs/_js/html5shiv.min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
||||
*/
|
||||
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
|
||||
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
|
||||
c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
|
||||
"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video",version:"3.6.2",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment();
|
||||
for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);
|
||||
@@ -6,14 +6,22 @@ var HELLO_COMPONENT = "\
|
||||
/** @jsx React.DOM */\n\
|
||||
var HelloMessage = React.createClass({\n\
|
||||
render: function() {\n\
|
||||
return <div>{'Hello ' + this.props.name}</div>;\n\
|
||||
return <div>Hello {this.props.name}</div>;\n\
|
||||
}\n\
|
||||
});\n\
|
||||
\n\
|
||||
React.renderComponent(<HelloMessage name=\"John\" />, mountNode);\
|
||||
";
|
||||
|
||||
var transformer = function(code) {
|
||||
return JSXTransformer.transform(code).code;
|
||||
}
|
||||
React.renderComponent(
|
||||
<ReactPlayground codeText={HELLO_COMPONENT} renderCode={true} />,
|
||||
<ReactPlayground
|
||||
codeText={HELLO_COMPONENT}
|
||||
renderCode={true}
|
||||
transformer={transformer}
|
||||
showCompiledJSTab={false}
|
||||
/>,
|
||||
document.getElementById('jsxCompiler')
|
||||
);
|
||||
|
||||
@@ -14,25 +14,33 @@ var IS_MOBILE = (
|
||||
);
|
||||
|
||||
var CodeMirrorEditor = React.createClass({
|
||||
componentDidMount: function(root) {
|
||||
if (IS_MOBILE) {
|
||||
return;
|
||||
}
|
||||
componentDidMount: function() {
|
||||
if (IS_MOBILE) return;
|
||||
|
||||
this.editor = CodeMirror.fromTextArea(this.refs.editor.getDOMNode(), {
|
||||
mode: 'javascript',
|
||||
lineNumbers: false,
|
||||
lineWrapping: true,
|
||||
smartIndent: false, // javascript mode does bad things with jsx indents
|
||||
matchBrackets: true,
|
||||
theme: 'solarized-light'
|
||||
theme: 'solarized-light',
|
||||
readOnly: this.props.readOnly
|
||||
});
|
||||
this.editor.on('change', this.onChange);
|
||||
this.onChange();
|
||||
this.editor.on('change', this.handleChange);
|
||||
},
|
||||
onChange: function() {
|
||||
if (this.props.onChange) {
|
||||
var content = this.editor.getValue();
|
||||
this.props.onChange(content);
|
||||
|
||||
componentDidUpdate: function() {
|
||||
if (this.props.readOnly) {
|
||||
this.editor.setValue(this.props.codeText);
|
||||
}
|
||||
},
|
||||
|
||||
handleChange: function() {
|
||||
if (!this.props.readOnly) {
|
||||
this.props.onChange && this.props.onChange(this.editor.getValue());
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
// wrap in a div to fully contain CodeMirror
|
||||
var editor;
|
||||
@@ -44,87 +52,159 @@ var CodeMirrorEditor = React.createClass({
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={this.props.className}>
|
||||
<div style={this.props.style} className={this.props.className}>
|
||||
{editor}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var selfCleaningTimeout = {
|
||||
componentDidUpdate: function() {
|
||||
clearTimeout(this.timeoutID);
|
||||
},
|
||||
|
||||
setTimeout: function() {
|
||||
clearTimeout(this.timeoutID);
|
||||
this.timeoutID = setTimeout.apply(null, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
var ReactPlayground = React.createClass({
|
||||
MODES: {XJS: 'XJS', JS: 'JS'}, //keyMirror({XJS: true, JS: true}),
|
||||
mixins: [selfCleaningTimeout],
|
||||
|
||||
MODES: {JSX: 'JSX', JS: 'JS'}, //keyMirror({JSX: true, JS: true}),
|
||||
|
||||
propTypes: {
|
||||
codeText: React.PropTypes.string.isRequired,
|
||||
transformer: React.PropTypes.func,
|
||||
renderCode: React.PropTypes.bool,
|
||||
},
|
||||
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
transformer: function(code) {
|
||||
return JSXTransformer.transform(code).code;
|
||||
},
|
||||
showCompiledJSTab: true
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {mode: this.MODES.XJS, code: this.props.codeText};
|
||||
return {
|
||||
mode: this.MODES.JSX,
|
||||
code: this.props.codeText,
|
||||
};
|
||||
},
|
||||
|
||||
bindState: function(name) {
|
||||
return function(value) {
|
||||
var newState = {};
|
||||
newState[name] = value;
|
||||
this.setState(newState);
|
||||
}.bind(this);
|
||||
handleCodeChange: function(value) {
|
||||
this.setState({code: value});
|
||||
this.executeCode();
|
||||
},
|
||||
|
||||
getDesugaredCode: function() {
|
||||
return JSXTransformer.transform(this.state.code).code;
|
||||
handleCodeModeSwitch: function(mode) {
|
||||
this.setState({mode: mode});
|
||||
},
|
||||
|
||||
compileCode: function() {
|
||||
return this.props.transformer(this.state.code);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var content;
|
||||
if (this.state.mode === this.MODES.XJS) {
|
||||
content =
|
||||
<CodeMirrorEditor
|
||||
onChange={this.bindState('code')}
|
||||
class="playgroundStage"
|
||||
codeText={this.state.code}
|
||||
/>;
|
||||
} else if (this.state.mode === this.MODES.JS) {
|
||||
content =
|
||||
<div class="playgroundJS playgroundStage">
|
||||
{this.getDesugaredCode()}
|
||||
</div>;
|
||||
}
|
||||
var isJS = this.state.mode === this.MODES.JS;
|
||||
var compiledCode = '';
|
||||
try {
|
||||
compiledCode = this.compileCode();
|
||||
} catch (err) {}
|
||||
|
||||
var JSContent =
|
||||
<CodeMirrorEditor
|
||||
key="js"
|
||||
className="playgroundStage CodeMirror-readonly"
|
||||
onChange={this.handleCodeChange}
|
||||
codeText={compiledCode}
|
||||
readOnly={true}
|
||||
/>;
|
||||
|
||||
var JSXContent =
|
||||
<CodeMirrorEditor
|
||||
key="jsx"
|
||||
onChange={this.handleCodeChange}
|
||||
className="playgroundStage"
|
||||
codeText={this.state.code}
|
||||
/>;
|
||||
|
||||
var JSXTabClassName =
|
||||
'playground-tab' + (isJS ? '' : ' playground-tab-active');
|
||||
var JSTabClassName =
|
||||
'playground-tab' + (isJS ? ' playground-tab-active' : '');
|
||||
|
||||
var JSTab =
|
||||
<div
|
||||
className={JSTabClassName}
|
||||
onClick={this.handleCodeModeSwitch.bind(this, this.MODES.JS)}>
|
||||
Compiled JS
|
||||
</div>;
|
||||
|
||||
var JSXTab =
|
||||
<div
|
||||
className={JSXTabClassName}
|
||||
onClick={this.handleCodeModeSwitch.bind(this, this.MODES.JSX)}>
|
||||
Live JSX Editor
|
||||
</div>
|
||||
|
||||
return (
|
||||
<div class="playground">
|
||||
<div class="playgroundCode">
|
||||
{content}
|
||||
<div className="playground">
|
||||
<div>
|
||||
{JSXTab}
|
||||
{this.props.showCompiledJSTab && JSTab}
|
||||
</div>
|
||||
<div class="playgroundPreview">
|
||||
<div className="playgroundCode">
|
||||
{isJS ? JSContent : JSXContent}
|
||||
</div>
|
||||
<div className="playgroundPreview">
|
||||
<div ref="mount" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
this.executeCode();
|
||||
},
|
||||
componentDidUpdate: function() {
|
||||
this.executeCode();
|
||||
|
||||
componentWillUpdate: function(nextProps, nextState) {
|
||||
// execute code only when the state's not being updated by switching tab
|
||||
// this avoids re-displaying the error, which comes after a certain delay
|
||||
if (this.state.code !== nextState.code) {
|
||||
this.executeCode();
|
||||
}
|
||||
},
|
||||
|
||||
executeCode: function() {
|
||||
var mountNode = this.refs.mount.getDOMNode();
|
||||
|
||||
try {
|
||||
React.unmountAndReleaseReactRootNode(mountNode);
|
||||
React.unmountComponentAtNode(mountNode);
|
||||
} catch (e) { }
|
||||
|
||||
try {
|
||||
var compiledCode = this.compileCode();
|
||||
if (this.props.renderCode) {
|
||||
React.renderComponent(
|
||||
<pre>{this.getDesugaredCode()}</pre>,
|
||||
<CodeMirrorEditor codeText={compiledCode} readOnly={true} />,
|
||||
mountNode
|
||||
);
|
||||
} else {
|
||||
eval(this.getDesugaredCode());
|
||||
eval(compiledCode);
|
||||
}
|
||||
} catch (e) {
|
||||
React.renderComponent(
|
||||
<div content={e.toString()} class="playgroundError" />,
|
||||
mountNode
|
||||
);
|
||||
} catch (err) {
|
||||
this.setTimeout(function() {
|
||||
React.renderComponent(
|
||||
<div className="playgroundError">{err.toString()}</div>,
|
||||
mountNode
|
||||
);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<!--[if IE]><![endif]-->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@@ -10,17 +11,23 @@
|
||||
<meta property="og:url" content="http://facebook.github.io/react{{ page.url }}" />
|
||||
<meta property="og:image" content="http://facebook.github.io/react/img/logo_og.png" />
|
||||
<meta property="og:description" content="A JavaScript library for building user interfaces" />
|
||||
<meta property="fb:app_id" content="623268441017527" />
|
||||
|
||||
<link rel="shortcut icon" href="/react/favicon.ico">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}{{ site.baseurl }}/feed.xml">
|
||||
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
<link rel="stylesheet" href="/react/css/syntax.css">
|
||||
<link rel="stylesheet" href="/react/css/codemirror.css">
|
||||
<link rel="stylesheet" href="/react/css/react.css">
|
||||
|
||||
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
|
||||
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
|
||||
|
||||
<!--[if lte IE 8]>
|
||||
<script type="text/javascript" src="/react/js/html5shiv.min.js"></script>
|
||||
<script type="text/javascript" src="/react/js/es5-shim.min.js"></script>
|
||||
<script type="text/javascript" src="/react/js/es5-sham.min.js"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript" src="/react/js/codemirror.js"></script>
|
||||
<script type="text/javascript" src="/react/js/javascript.js"></script>
|
||||
<script type="text/javascript" src="/react/js/react.min.js"></script>
|
||||
@@ -39,13 +46,12 @@
|
||||
React
|
||||
</a>
|
||||
<ul class="nav-site">
|
||||
<li><a href="/react/docs/getting-started.html"{% if page.sectionid == 'docs' %} class="active"{% endif %}>docs</a></li>
|
||||
<li><a href="/react/docs/getting-started.html"{% if page.sectionid == 'docs' or page.sectionid == 'tips' %} class="active"{% endif %}>docs</a></li>
|
||||
<li><a href="/react/support.html"{% if page.id == 'support' %} class="active"{% endif %}>support</a></li>
|
||||
<li><a href="/react/downloads.html"{% if page.id == 'downloads' %} class="active"{% endif %}>download</a></li>
|
||||
<li><a href="/react/blog/"{% if page.sectionid == 'blog' %} class="active"{% endif %}>blog</a></li>
|
||||
<li><a href="http://github.com/facebook/react">github</a>
|
||||
</ul>
|
||||
<!-- <iframe src="http://ghbtns.com/github-btn.html?user=facebook&repo=react.js&type=fork"allowtransparency="true" frameborder="0" scrolling="0" width="62" height="20"></iframe> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -68,11 +74,15 @@
|
||||
{{ content }}
|
||||
|
||||
<footer class="wrap">
|
||||
<div class="left">A Facebook & Instagram collaboration.</div>
|
||||
<div class="right">© 2013 Facebook Inc.</div>
|
||||
<div class="left">
|
||||
A Facebook & Instagram collaboration.<br>
|
||||
<a href="/react/acknowledgements.html">Acknowledgements</a>
|
||||
</div>
|
||||
<div class="right">© 2014 Facebook Inc.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<div id="fb-root"></div>
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
|
||||
6
docs/_layouts/redirect.html
Normal file
6
docs/_layouts/redirect.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0; {{ page.destination }}">
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
25
docs/_layouts/tips.html
Normal file
25
docs/_layouts/tips.html
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
layout: default
|
||||
sectionid: tips
|
||||
---
|
||||
|
||||
<section class="content wrap documentationContent">
|
||||
{% include nav_docs.html %}
|
||||
|
||||
<div class="inner-content">
|
||||
<h1>{{ page.title }}</h1>
|
||||
<div class="subHeader">{{ page.description }}</div>
|
||||
{{ content }}
|
||||
|
||||
<div class="docs-prevnext">
|
||||
{% if page.prev %}
|
||||
<a class="docs-prev" href="/react/tips/{{ page.prev }}">← Prev</a>
|
||||
{% endif %}
|
||||
{% if page.next %}
|
||||
<a class="docs-next" href="/react/tips/{{ page.next }}">Next →</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="fb-comments" data-width="650" data-num-posts="10" data-href="{{ site.url }}{{ site.baseurl }}{{ page.url }}"></div>
|
||||
</div>
|
||||
</section>
|
||||
17
docs/_plugins/header_links.rb
Normal file
17
docs/_plugins/header_links.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
require 'redcarpet'
|
||||
require 'sanitize'
|
||||
|
||||
# Simple converter that is probably better than RedCarpet's built in TOC id
|
||||
# generator (which ends up with things lik id="toc_1"... terrible).
|
||||
|
||||
class Redcarpet::Render::HTML
|
||||
def header(title, level)
|
||||
clean_title = Sanitize.clean(title)
|
||||
.downcase
|
||||
.gsub(/\s+/, "-")
|
||||
.gsub(/[^A-Za-z0-9\-_.]/, "")
|
||||
|
||||
return "<h#{level}><a class=\"anchor\" name=\"#{clean_title}\"></a>#{title} <a class=\"hash-link\" href=\"##{clean_title}\">#</a></h#{level}>"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -20,8 +20,8 @@ These templates dictate the full set of abstractions that you are allowed to use
|
||||
to build your UI.
|
||||
|
||||
React approaches building user interfaces differently by breaking them into
|
||||
**components**. This means React uses JavaScript to generate markup, which we
|
||||
see as an advantage over templates for a few reasons:
|
||||
**components**. This means React uses a real, full featured programming language
|
||||
to render views, which we see as an advantage over templates for a few reasons:
|
||||
|
||||
- **JavaScript is a flexible, powerful programming language** with the ability
|
||||
to build abstractions. This is incredibly important in large applications.
|
||||
@@ -31,8 +31,8 @@ see as an advantage over templates for a few reasons:
|
||||
**no manual string concatenation** and therefore less surface area for XSS
|
||||
vulnerabilities.
|
||||
|
||||
We've also created [JSX](http://facebook.github.io/react/docs/syntax.html), an optional
|
||||
syntax extension, in case you prefer the readability of HTML to raw JavaScript.
|
||||
We've also created [JSX](/react/docs/jsx-in-depth.html), an optional syntax
|
||||
extension, in case you prefer the readability of HTML to raw JavaScript.
|
||||
|
||||
## Reactive updates are dead simple.
|
||||
|
||||
@@ -41,7 +41,7 @@ React really shines when your data changes over time.
|
||||
In a traditional JavaScript application, you need to look at what data changed
|
||||
and imperatively make changes to the DOM to keep it up-to-date. Even AngularJS,
|
||||
which provides a declarative interface via directives and data binding [requires
|
||||
a linking function to manually update DOM nodes](http://docs.angularjs.org/guide/directive#reasonsbehindthecompilelinkseparation).
|
||||
a linking function to manually update DOM nodes](http://code.angularjs.org/1.0.8/docs/guide/directive#reasonsbehindthecompilelinkseparation).
|
||||
|
||||
React takes a different approach.
|
||||
|
||||
@@ -81,11 +81,9 @@ some pretty cool things with it:
|
||||
(including IE8) and automatically use
|
||||
[event delegation](http://davidwalsh.name/event-delegate).
|
||||
|
||||
Head on over to
|
||||
[facebook.github.io/react](http://facebook.github.io/react) to check
|
||||
out what we have built. Our documentation is geared towards building
|
||||
apps with the framework, but if you are interested in the
|
||||
nuts and bolts
|
||||
[get in touch](http://facebook.github.io/react/support.html) with us!
|
||||
Head on over to [facebook.github.io/react](/react) to check out what we have
|
||||
built. Our documentation is geared towards building apps with the framework,
|
||||
but if you are interested in the nuts and bolts
|
||||
[get in touch](/react/support.html) with us!
|
||||
|
||||
Thanks for reading!
|
||||
|
||||
@@ -23,7 +23,7 @@ The best part is the demo of how React reconciliation process makes live editing
|
||||
|
||||
## React Snippets
|
||||
|
||||
Over the past several weeks, members of our team, [Pete Hunt](http://www.petehunt.net/) and [Paul O'Shannessy](http://zpao.com/), answered many questions that were asked in the [React group](https://groups.google.com/forum/#!forum/reactjs). They give a good overview of how to integrate React with other libraries and APIs through the use of [Mixins](/react/docs/mixins.html) and [Lifecycle Methods](/react/docs/advanced-components.html).
|
||||
Over the past several weeks, members of our team, [Pete Hunt](http://www.petehunt.net/) and [Paul O'Shannessy](http://zpao.com/), answered many questions that were asked in the [React group](https://groups.google.com/forum/#!forum/reactjs). They give a good overview of how to integrate React with other libraries and APIs through the use of [Mixins](/react/docs/reusable-components.html) and [Lifecycle Methods](/react/docs/working-with-the-browser.html).
|
||||
|
||||
> [Listening Scroll Event](https://groups.google.com/forum/#!topic/reactjs/l6PnP8qbofk)
|
||||
>
|
||||
|
||||
@@ -24,7 +24,7 @@ When you're ready, [go download it](/react/downloads.html)!
|
||||
* Removed `React.autoBind`. [Read our blog post for details...](http://facebook.github.io/react/blog/2013/07/02/react-v0-4-autobind-by-default.html)
|
||||
* Improvements to forms. We've written wrappers around `<input>`, `<textarea>`, `<option>`, and `<select>` in order to standardize many inconsistencies in browser implementations. This includes support for `defaultValue`, and improved implementation of the `onChange` event, and circuit completion. [Read the docs for details...](http://facebook.github.io/react/docs/forms.html)
|
||||
* We've implemented an improved synthetic event system that conforms to the W3C spec.
|
||||
* Updates to your component are batched now, which may result in a significantly faster re-render of components. `this.setState` now takes an optional callback as it's second parameter. If you were using `onClick={this.setState.bind(this, state)}` previously, you'll want to make sure you add a third parameter so that the event is not treated as the callback.
|
||||
* Updates to your component are batched now, which may result in a significantly faster re-render of components. `this.setState` now takes an optional callback as its second parameter. If you were using `onClick={this.setState.bind(this, state)}` previously, you'll want to make sure you add a third parameter so that the event is not treated as the callback.
|
||||
|
||||
### JSX
|
||||
|
||||
|
||||
@@ -96,4 +96,4 @@ React.renderComponent(
|
||||
> * [Working With the Browser](/react/docs/working-with-the-browser.html)
|
||||
> * [More About Refs](/react/docs/more-about-refs.html)
|
||||
> * [Tooling integration](/react/docs/tooling-integration.html)
|
||||
> * [Reference](/react/docs/reference.html)
|
||||
> * [Reference](/react/docs/top-level-api.html)
|
||||
|
||||
25
docs/_posts/2013-07-26-react-v0-4-1.md
Normal file
25
docs/_posts/2013-07-26-react-v0-4-1.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "React v0.4.1"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
React v0.4.1 is a small update, mostly containing correctness fixes. Some code has been restructured internally but those changes do not impact any of our public APIs.
|
||||
|
||||
|
||||
## React
|
||||
|
||||
* `setState` callbacks are now executed in the scope of your component.
|
||||
* `click` events now work on Mobile Safari.
|
||||
* Prevent a potential error in event handling if `Object.prototype` is extended.
|
||||
* Don't set DOM attributes to the string `"undefined"` on update when previously defined.
|
||||
* Improved support for `<iframe>` attributes.
|
||||
* Added checksums to detect and correct cases where server-side rendering markup mismatches what React expects client-side.
|
||||
|
||||
|
||||
## JSXTransformer
|
||||
|
||||
* Improved environment detection so it can be run in a non-browser environment.
|
||||
|
||||
|
||||
[Download it now!](/react/downloads.html)
|
||||
54
docs/_posts/2013-07-30-use-react-and-jsx-in-ruby-on-rails.md
Normal file
54
docs/_posts/2013-07-30-use-react-and-jsx-in-ruby-on-rails.md
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: "Use React and JSX in Ruby on Rails"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
Today we're releasing a gem to make it easier to use React and JSX in Ruby on Rails applications: [react-rails](https://github.com/facebook/react-rails).
|
||||
|
||||
|
||||
This gem has 2 primary purposes:
|
||||
|
||||
1. To package `react.js` in a way that's easy to use and easy to update.
|
||||
2. To allow you to write JSX without an external build step to transform that into JS.
|
||||
|
||||
|
||||
## Packaging react.js
|
||||
|
||||
To make `react.js` available for use client-side, simply add `react` to your manifest, and declare the variant you'd like to use in your environment. When you use `:production`, the minified and optimized `react.min.js` will be used instead of the development version. For example:
|
||||
|
||||
```ruby
|
||||
# config/environments/development.rb
|
||||
|
||||
MyApp::Application.configure do
|
||||
config.react.variant = :development
|
||||
# use :production in production.rb
|
||||
end
|
||||
```
|
||||
|
||||
```js
|
||||
// app/assets/javascript/application.js
|
||||
|
||||
//= require react
|
||||
```
|
||||
|
||||
|
||||
## Writing JSX
|
||||
|
||||
When you name your file with `myfile.js.jsx`, `react-rails` will automatically try to transform that file. For the time being, we still require that you include the docblock at the beginning of the file. For example, this file will get transformed on request.
|
||||
|
||||
```js
|
||||
/** @jsx React.DOM */
|
||||
React.renderComponent(<MyComponent/>, document.body)
|
||||
```
|
||||
|
||||
|
||||
## Asset Pipeline
|
||||
|
||||
`react-rails` takes advantage of the [asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html) that was introduced in Rails 3.1. A very important part of that pipeline is the `assets:precompile` Rake task. `react-rails` will ensure that your JSX files will be transformed into regular JS before all of your assets are minified and packaged.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Installation follows the same process you're familiar with. You can install it globally with `gem install react-rails`, though we suggest you add the dependency to your `Gemfile` directly.
|
||||
|
||||
80
docs/_posts/2013-08-05-community-roundup-6.md
Normal file
80
docs/_posts/2013-08-05-community-roundup-6.md
Normal file
@@ -0,0 +1,80 @@
|
||||
---
|
||||
title: "Community Round-up #6"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
This is the first Community Round-up where none of the items are from Facebook/Instagram employees. It's great to see the adoption of React growing.
|
||||
|
||||
## React Game Tutorial
|
||||
|
||||
[Caleb Cassel](https://twitter.com/CalebCassel) wrote a [step-by-step tutorial](https://rawgithub.com/calebcassel/react-demo/master/part1.html) about making a small game. It covers JSX, State and Events, Embedded Components and Integration with Backbone.
|
||||
<figure>[](https://rawgithub.com/calebcassel/react-demo/master/part1.html)</figure>
|
||||
|
||||
|
||||
## Reactify
|
||||
|
||||
[Andrey Popp](http://andreypopp.com/) created a [Browserify](http://browserify.org/) helper to compile JSX files.
|
||||
|
||||
> Browserify v2 transform for `text/jsx`. Basic usage is:
|
||||
>
|
||||
> ```
|
||||
% browserify -t reactify main.jsx
|
||||
```
|
||||
>
|
||||
> `reactify` transform activates for files with either `.jsx` extension or `/** @jsx React.DOM */` pragma as a first line for any `.js` file.
|
||||
>
|
||||
> [Check it out on Github...](https://github.com/andreypopp/reactify)
|
||||
|
||||
|
||||
|
||||
## React Integration with Este
|
||||
|
||||
[Daniel Steigerwald](http://daniel.steigerwald.cz/) is now using React within [Este](https://github.com/steida/este), which is a development stack for web apps in CoffeeScript that are statically typed using the Closure Library.
|
||||
|
||||
```coffeescript
|
||||
este.demos.react.todoApp = este.react.create (`/** @lends {React.ReactComponent.prototype} */`)
|
||||
render: ->
|
||||
@div [
|
||||
este.demos.react.todoList 'items': @state['items']
|
||||
if @state['items'].length
|
||||
@p "#{@state['items'].length} items."
|
||||
@form 'onSubmit': @onFormSubmit, [
|
||||
@input
|
||||
'onChange': @onChange
|
||||
'value': @state['text']
|
||||
'autoFocus': true
|
||||
'ref': 'textInput'
|
||||
@button "Add ##{@state['items'].length + 1}"
|
||||
]
|
||||
]
|
||||
```
|
||||
|
||||
[Check it out on Github...](https://github.com/steida/este-library/blob/master/este/demos/thirdparty/react/start.coffee)
|
||||
|
||||
|
||||
## React Stylus Boilerplate
|
||||
|
||||
[Zaim Bakar](http://zaim.github.io/) shared his boilerplate to get started with Stylus CSS processor.
|
||||
|
||||
> This is my boilerplate React project using Grunt as the build tool, and Stylus as my CSS preprocessor.
|
||||
>
|
||||
> - Very minimal HTML boilerplate
|
||||
> - Uses Stylus, with nib included
|
||||
> - Uses two build targets:
|
||||
> - `grunt build` to compile JSX and Stylus into a development build
|
||||
> - `grunt dist` to minify and optimize the development build for production
|
||||
>
|
||||
> [Check it out on Github...](https://github.com/zaim/react-stylus-boilerplate)
|
||||
|
||||
|
||||
## WebFUI
|
||||
|
||||
[Conrad Barski](http://lisperati.com/), author of the popular book [Land of Lisp](http://landoflisp.com/), wants to use React for his ClojureScript library called [WebFUI](https://github.com/drcode/webfui).
|
||||
|
||||
> I'm the author of "[Land of Lisp](http://landoflisp.com/)" and I love your framework. I built a somewhat similar framework a year ago [WebFUI](https://github.com/drcode/webfui) aimed at ClojureScript. My framework also uses global event delegates, a global "render" function, DOM reconciliation, etc just like react.js. (Of course these ideas all have been floating around the ether for ages, always great to see more people building on them.)
|
||||
>
|
||||
> Your implementation is more robust, and so I think the next point release of webfui will simply delegate all the "hard work" to react.js and will only focus on the areas where it adds value (enabling purely functional UI programming in clojurescript, and some other stuff related to streamlining event handling)
|
||||
<figure>[](https://groups.google.com/forum/#!msg/reactjs/e3bYersyd64/qODfcuBR9LwJ)</figure>
|
||||
>
|
||||
> [Read the full post...](https://groups.google.com/forum/#!msg/reactjs/e3bYersyd64/qODfcuBR9LwJ)
|
||||
@@ -0,0 +1,56 @@
|
||||
---
|
||||
title: "Use React and JSX in Python Applications"
|
||||
layout: post
|
||||
author: Kunal Mehta
|
||||
---
|
||||
|
||||
Today we're happy to announce the initial release of [PyReact](https://github.com/facebook/react-python), which makes it easier to use React and JSX in your Python applications. It's designed to provide an API to transform your JSX files into JavaScript, as well as provide access to the latest React source files.
|
||||
|
||||
## Usage
|
||||
|
||||
Transform your JSX files via the provided `jsx` module:
|
||||
|
||||
```python
|
||||
from react import jsx
|
||||
|
||||
# For multiple paths, use the JSXTransformer class.
|
||||
transformer = jsx.JSXTransformer()
|
||||
for jsx_path, js_path in my_paths:
|
||||
transformer.transform(jsx_path, js_path)
|
||||
|
||||
# For a single file, you can use a shortcut method.
|
||||
jsx.transform('path/to/input/file.jsx', 'path/to/output/file.js')
|
||||
```
|
||||
|
||||
For full paths to React files, use the `source` module:
|
||||
|
||||
```python
|
||||
from react import source
|
||||
|
||||
# path_for raises IOError if the file doesn't exist.
|
||||
react_js = source.path_for('react.min.js')
|
||||
```
|
||||
|
||||
## Django
|
||||
|
||||
PyReact includes a JSX compiler for [django-pipeline](https://github.com/cyberdelia/django-pipeline). Add it to your project's pipeline settings like this:
|
||||
|
||||
```python
|
||||
PIPELINE_COMPILERS = (
|
||||
'react.utils.pipeline.JSXCompiler',
|
||||
)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
PyReact is hosted on PyPI, and can be installed with `pip`:
|
||||
|
||||
$ pip install PyReact
|
||||
|
||||
Alternatively, add it into your `requirements` file:
|
||||
|
||||
PyReact==0.1.1
|
||||
|
||||
**Dependencies**: PyReact uses [PyExecJS](https://github.com/doloopwhile/PyExecJS) to execute the bundled React code, which requires that a JS runtime environment is installed on your machine. We don't explicitly set a dependency on a runtime environment; Mac OS X comes bundled with one. If you're on a different platform, we recommend [PyV8](https://code.google.com/p/pyv8/).
|
||||
|
||||
For the initial release, we've only tested on Python 2.7. Look out for support for Python 3 in the future, and if you see anything that can be improved, we welcome your [contributions](https://github.com/facebook/react-python/blob/master/CONTRIBUTING.md)!
|
||||
74
docs/_posts/2013-08-26-community-roundup-7.md
Normal file
74
docs/_posts/2013-08-26-community-roundup-7.md
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
title: "Community Round-up #7"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
It's been three months since we open sourced React and it is going well. Some stats so far:
|
||||
|
||||
* 114 285 unique visitors on this website
|
||||
* [1933 stars](https://github.com/facebook/react/stargazers) and [210 forks](https://github.com/facebook/react/network/members)
|
||||
* [226 posts on Google Group](https://groups.google.com/forum/#!forum/reactjs)
|
||||
* [76 Github projects using React](https://gist.github.com/vjeux/6335762)
|
||||
* [30 contributors](https://github.com/facebook/react/graphs/contributors)
|
||||
* [15 blog posts](http://facebook.github.io/react/blog/)
|
||||
* 2 early adopters: [Khan Academy](http://benalpert.com/2013/06/09/using-react-to-speed-up-khan-academy.html) and [Propeller](http://usepropeller.com/blog/posts/from-backbone-to-react/)
|
||||
|
||||
|
||||
## Wolfenstein Rendering Engine Ported to React
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) ported the render code of the web version of Wolfenstein 3D to React. Check out [the demo](http://www.petehunt.net/wolfenstein3D-react/wolf3d.html) and [render.js](https://github.com/petehunt/wolfenstein3D-react/blob/master/js/renderer.js#L183) file for the implementation.
|
||||
<figure>[](http://www.petehunt.net/wolfenstein3D-react/wolf3d.html)</figure>
|
||||
|
||||
|
||||
## React & Meteor
|
||||
|
||||
[Ben Newman](https://twitter.com/benjamn) made a [13-lines wrapper](https://github.com/benjamn/meteor-react/blob/master/lib/mixin.js) to use React and Meteor together. [Meteor](http://www.meteor.com/) handles the real-time data synchronization between client and server. React provides the declarative way to write the interface and only updates the parts of the UI that changed.
|
||||
|
||||
> This repository defines a Meteor package that automatically integrates the React rendering framework on both the client and the server, to complement or replace the default Handlebars templating system.
|
||||
>
|
||||
> The React core is officially agnostic about how you fetch and update your data, so it is far from obvious which approach is the best. This package provides one answer to that question (use Meteor!), and I hope you will find it a compelling combination.
|
||||
>
|
||||
>```javascript
|
||||
>var MyComponent = React.createClass({
|
||||
> mixins: [MeteorMixin],
|
||||
>
|
||||
> getMeteorState: function() {
|
||||
> return { foo: Session.get('foo') };
|
||||
> },
|
||||
>
|
||||
> render: function() {
|
||||
> return <div>{this.state.foo}</div>;
|
||||
> }
|
||||
>});
|
||||
>```
|
||||
>
|
||||
> Dependencies will be registered for any data accesses performed by getMeteorState so that the component can be automatically re-rendered whenever the data changes.
|
||||
>
|
||||
> [Read more ...](https://github.com/benjamn/meteor-react)
|
||||
|
||||
## React Page
|
||||
|
||||
[Jordan Walke](https://github.com/jordwalke) implemented a complete React project creator called [react-page](https://github.com/facebook/react-page/). It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.
|
||||
|
||||
> Easy Application Development with React JavaScript
|
||||
> <figure>[](https://github.com/facebook/react-page/)</figure>
|
||||
>
|
||||
> **Why Server Rendering?**
|
||||
>
|
||||
> * Faster initial page speed:
|
||||
> * Markup displayed before downloading large JavaScript.
|
||||
> * Markup can be generated more quickly on a fast server than low power client devices.
|
||||
> * Faster Development and Prototyping:
|
||||
> * Instantly refresh your app without waiting for any watch scripts or bundlers.
|
||||
> * Easy deployment of static content pages/blogs: just archive using recursive wget.
|
||||
> * SEO benefits of indexability and perf.
|
||||
>
|
||||
> **How Does Server Rendering Work?**
|
||||
>
|
||||
> * `react-page` computes page markup on the server, sends it to the client so the user can see it quickly.
|
||||
> * The corresponding JavaScript is then packaged and sent.
|
||||
> * The browser runs that JavaScript, so that all of the event handlers, interactions and update code will run seamlessly on top of the server generated markup.
|
||||
> * From the developer's (and the user's) perspective, it's just as if the rendering occurred on the client, only faster.
|
||||
>
|
||||
> [Try it out ...](https://github.com/facebook/react-page/)
|
||||
70
docs/_posts/2013-09-24-community-roundup-8.md
Normal file
70
docs/_posts/2013-09-24-community-roundup-8.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
title: "Community Round-up #8"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
A lot has happened in the month since our last update. Here are some of the more interesting things we've found. But first, we have a couple updates before we share links.
|
||||
|
||||
First, we are organizing a [React Hackathon](http://reactjshack-a-thon.splashthat.com/) in Facebook's Seattle office on Saturday September 28. If you want to hack on React, meet some of the team or win some prizes, feel free to join us!
|
||||
|
||||
We've also reached a point where there are too many questions for us to handle directly. We're encouraging people to ask questions on [StackOverflow](http://stackoverflow.com/questions/tagged/reactjs) using the tag [[reactjs]](http://stackoverflow.com/questions/tagged/reactjs). Many members of the team and community have subscribed to the tag, so feel free to ask questions there. We think these will be more discoverable than Google Groups archives or IRC logs.
|
||||
|
||||
## Javascript Jabber
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) and [Jordan Walke](https://github.com/jordwalke) were interviewed on [Javascript Jabber](http://javascriptjabber.com/073-jsj-react-with-pete-hunt-and-jordan-walke/) for an hour. They go over many aspects of React such as 60 FPS, Data binding, Performance, Diffing Algorithm, DOM Manipulation, Node.js support, server-side rendering, JSX, requestAnimationFrame and the community. This is a gold mine of information about React.
|
||||
|
||||
> **PETE:** So React was designed all around that. Conceptually, how you build a React app is that every time your data changes, it's like hitting the refresh button in a server-rendered app. What we do is we conceptually throw out all of the markup and event handlers that you've registered and we reset the whole page and then we redraw the entire page. If you're writing a server-rendered app, handling updates is really easy because you hit the refresh button and you're pretty much guaranteed to get what you expect.
|
||||
>
|
||||
> **MERRICK:** That's true. You don't get into these odd states.
|
||||
>
|
||||
> **PETE:** Exactly, exactly. In order to implement that, we communicate it as a fake DOM. What we'll do is rather than throw out the actual browser html and event handlers, we have an internal representation of what the page looks like and then we generate a brand new representation of what we want the page to look like. Then we perform this really, really fast diffing algorithm between those two page representations, DOM representations. Then React will compute the minimum set of DOM mutations it needs to make to bring the page up to date.
|
||||
>
|
||||
> Then to finally get to answer your question, that set of DOM mutations then goes into a queue and we can plug in arbitrary flushing strategies for that. For example, when we originally launched React in open source, every setState would immediately trigger a flush to the DOM. That wasn't part of the contract of setState, but that was just our strategy and it worked pretty well. Then this totally awesome open source contributor Ben Alpert at Khan Academy built a new batching strategy which would basically queue up every single DOM update and state change that happened within an event tick and would execute them in bulk at the end of the event tick.
|
||||
>
|
||||
> [Read the full conversation ...](http://javascriptjabber.com/073-jsj-react-with-pete-hunt-and-jordan-walke/)
|
||||
|
||||
|
||||
## JSXTransformer Trick
|
||||
|
||||
While this is not going to work for all the attributes since they are camelCased in React, this is a pretty cool trick.
|
||||
|
||||
<div style="margin-left: 74px;"><blockquote class="twitter-tweet"><p>Turn any DOM element into a React.js function: JSXTransformer.transform("/** <a href="https://twitter.com/jsx">@jsx</a> React.DOM */" + element.innerHTML).code</p>— Ross Allen (@ssorallen) <a href="https://twitter.com/ssorallen/statuses/377105575441489920">September 9, 2013</a></blockquote></div>
|
||||
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
|
||||
|
||||
|
||||
## Remarkable React
|
||||
|
||||
[Stoyan Stefanov](http://www.phpied.com/) gave a talk at [BrazilJS](http://braziljs.com.br/) about React and wrote an article with the content of the presentation. He goes through the difficulties of writting _active apps_ using the DOM API and shows how React handles it.
|
||||
|
||||
> So how does exactly React deal with it internally? Two crazy ideas - virtual DOM and synthetic events.
|
||||
>
|
||||
> You define you components in React. It builds a virtual DOM in JavaScript land which is way more efficient. Then it updates the DOM. (And "virtual DOM" is a very big name for what is simply a JavaScript object with nested key-value pairs)
|
||||
>
|
||||
> Data changes. React computes a diff (in JavaScript land, which is, of course, much more efficient) and updates the single table cell that needs to change. React replicates the state of the virtual DOM into the actual DOM only when and where it's necessary. And does it all at once, in most cases in a single tick of the `requestAnimationFrame()`.
|
||||
>
|
||||
> What about event handlers? They are synthetic. React uses event delegation to listen way at the top of the React tree. So removing a node in the virtual DOM has no effect on the event handling.
|
||||
>
|
||||
> The events are automatically cross-browser (they are React events). They are also much closer to W3C than any browser. That means that for example `e.target` works, no need to look for the event object or checking whether it's `e.target` or `e.srcElement` (IE). Bubbling and capturing phases also work cross browser. React also takes the liberty of making some small fixes, e.g. the event `<input onChange>` fires when you type, not when blur away from the input. And of course, event delegation is used as the most efficient way to handle events. You know that "thou shall use event delegation" is also commonly given advice for making web apps snappy.
|
||||
>
|
||||
> The good thing about the virtual DOM is that it's all in JavaScript land. You build all your UI in JavaScript. Which means it can be rendered on the server side, so you initial view is fast (and any SEO concerns are addressed). Also, if there are especially heavy operations they can be threaded into WebWorkers, which otherwise have no DOM access.
|
||||
>
|
||||
> [Read More ...](http://www.phpied.com/remarkable-react/)
|
||||
|
||||
|
||||
## Markdown in React
|
||||
|
||||
[Ben Alpert](http://benalpert.com/) converted [marked](https://github.com/chjj/marked), a Markdown Javascript implementation, in React: [marked-react](https://github.com/spicyj/marked-react). Even without using JSX, the HTML generation is now a lot cleaner. It is also safer as forgetting a call to `escape` will not introduce an XSS vulnerability.
|
||||
<figure>[](https://github.com/spicyj/marked-react/commit/cb70c9df6542c7c34ede9efe16f9b6580692a457)</figure>
|
||||
|
||||
|
||||
## Unite from BugBusters
|
||||
|
||||
[Renault John Lecoultre](https://twitter.com/renajohn) wrote [Unite](https://www.bugbuster.com/), an interactive tool for analyzing code dynamically using React. It integrates with CodeMirror.
|
||||
<figure>[](https://unite.bugbuster.com/)</figure>
|
||||
|
||||
## #reactjs IRC Logs
|
||||
|
||||
[Vjeux](http://blog.vjeux.com/) re-implemented the display part of the IRC logger in React. Just 130 lines are needed for a performant infinite scroll with timestamps and color-coded author names.
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/vjeux/QL9tz/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
52
docs/_posts/2013-10-16-react-v0.5.0.md
Normal file
52
docs/_posts/2013-10-16-react-v0.5.0.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
title: "React v0.5"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
This release is the result of several months of hard work from members of the team and the community. While there are no groundbreaking changes in core, we've worked hard to improve performance and memory usage. We've also worked hard to make sure we are being consistent in our usage of DOM properties.
|
||||
|
||||
The biggest change you'll notice as a developer is that we no longer support `class` in JSX as a way to provide CSS classes. Since this prop was being converted to `className` at the transform step, it caused some confusion when trying to access it in composite components. As a result we decided to make our DOM properties mirror their counterparts in the JS DOM API. There are [a few exceptions](https://github.com/facebook/react/blob/master/src/dom/DefaultDOMPropertyConfig.js#L156) where we deviate slightly in an attempt to be consistent internally.
|
||||
|
||||
The other major change in v0.5 is that we've added an additional build - `react-with-addons` - which adds support for some extras that we've been working on including animations and two-way binding. [Read more about these addons in the docs](/react/docs/addons.html).
|
||||
|
||||
## Thanks to Our Community
|
||||
|
||||
We added *22 new people* to the list of authors since we launched React v0.4.1 nearly 3 months ago. With a total of 48 names in our `AUTHORS` file, that means we've nearly doubled the number of contributors in that time period. We've seen the number of people contributing to discussion on IRC, mailing lists, Stack Overflow, and GitHub continue rising. We've also had people tell us about talks they've given in their local community about React.
|
||||
|
||||
It's been awesome to see the things that people are building with React, and we can't wait to see what you come up with next!
|
||||
|
||||
|
||||
## Changelog
|
||||
|
||||
### React
|
||||
|
||||
* Memory usage improvements - reduced allocations in core which will help with GC pauses
|
||||
* Performance improvements - in addition to speeding things up, we made some tweaks to stay out of slow path code in V8 and Nitro.
|
||||
* Standardized prop -> DOM attribute process. This previously resulting in additional type checking and overhead as well as confusing cases for users. Now we will always convert your value to a string before inserting it into the DOM.
|
||||
* Support for Selection events.
|
||||
* Support for [Composition events](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent).
|
||||
* Support for additional DOM properties (`charSet`, `content`, `form`, `httpEquiv`, `rowSpan`, `autoCapitalize`).
|
||||
* Support for additional SVG properties (`rx`, `ry`).
|
||||
* Support for using `getInitialState` and `getDefaultProps` in mixins.
|
||||
* Support mounting into iframes.
|
||||
* Bug fixes for controlled form components.
|
||||
* Bug fixes for SVG element creation.
|
||||
* Added `React.version`.
|
||||
* Added `React.isValidClass` - Used to determine if a value is a valid component constructor.
|
||||
* Removed `React.autoBind` - This was deprecated in v0.4 and now properly removed.
|
||||
* Renamed `React.unmountAndReleaseReactRootNode` to `React.unmountComponentAtNode`.
|
||||
* Began laying down work for refined performance analysis.
|
||||
* Better support for server-side rendering - [react-page](https://github.com/facebook/react-page) has helped improve the stability for server-side rendering.
|
||||
* Made it possible to use React in environments enforcing a strict [Content Security Policy](https://developer.mozilla.org/en-US/docs/Security/CSP/Introducing_Content_Security_Policy). This also makes it possible to use React to build Chrome extensions.
|
||||
|
||||
### React with Addons (New!)
|
||||
|
||||
* Introduced a separate build with several "addons" which we think can help improve the React experience. We plan to deprecate this in the long-term, instead shipping each as standalone pieces. [Read more in the docs](/react/docs/addons.html).
|
||||
|
||||
### JSX
|
||||
|
||||
* No longer transform `class` to `className` as part of the transform! This is a breaking change - if you were using `class`, you *must* change this to `className` or your components will be visually broken.
|
||||
* Added warnings to the in-browser transformer to make it clear it is not intended for production use.
|
||||
* Improved compatibility for Windows
|
||||
* Improved support for maintaining line numbers when transforming.
|
||||
25
docs/_posts/2013-10-29-react-v0-5-1.md
Normal file
25
docs/_posts/2013-10-29-react-v0-5-1.md
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: "React v0.5.1"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
This release focuses on fixing some small bugs that have been uncovered over the past two weeks. I would like to thank everybody involved, specifically members of the community who fixed half of the issues found. Thanks to [Ben Alpert][1], [Andrey Popp][2], and [Laurence Rowe][3] for their contributions!
|
||||
|
||||
## Changelog
|
||||
|
||||
### React
|
||||
|
||||
* Fixed bug with `<input type="range">` and selection events.
|
||||
* Fixed bug with selection and focus.
|
||||
* Made it possible to unmount components from the document root.
|
||||
* Fixed bug for `disabled` attribute handling on non-`<input>` elements.
|
||||
|
||||
### React with Addons
|
||||
|
||||
* Fixed bug with transition and animation event detection.
|
||||
|
||||
[1]: https://github.com/spicyj
|
||||
[2]: https://github.com/andreypopp
|
||||
[3]: https://github.com/lrowe
|
||||
|
||||
100
docs/_posts/2013-10-3-community-roundup-9.md
Normal file
100
docs/_posts/2013-10-3-community-roundup-9.md
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
title: "Community Round-up #9"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
We organized a React hackathon last week-end in the Facebook Seattle office. 50 people, grouped into 15 teams, came to hack for a day on React. It was a lot of fun and we'll probably organize more in the future.
|
||||
|
||||

|
||||
|
||||
|
||||
## React Hackathon Winner
|
||||
|
||||
[Alex Swan](http://bold-it.com/) implemented [Qu.izti.me](http://qu.izti.me/), a multi-player quiz game. It is real-time via Web Socket and mobile friendly.
|
||||
|
||||
> The game itself is pretty simple. People join the "room" by going to [http://qu.izti.me](http://qu.izti.me/) on their device. Large displays will show a leaderboard along with the game, and small displays (such as phones) will act as personal gamepads. Users will see questions and a choice of answers. The faster you answer, the more points you earn.
|
||||
>
|
||||
> In my opinion, Socket.io and React go together like chocolate and peanut butter. The page was always an accurate representation of the game object.
|
||||
><figure>[](http://bold-it.com/javascript/facebook-react-example/)</figure>
|
||||
>
|
||||
> [Read More...](http://bold-it.com/javascript/facebook-react-example/)
|
||||
|
||||
## JSConf EU Talk: Rethinking Best Practices
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) presented React at JSConf EU. He covers three controversial design decisions of React:
|
||||
|
||||
1. Build **components**, not templates
|
||||
2. Re-render the whole app on every update
|
||||
3. Virtual DOM
|
||||
|
||||
The video will be available soon on the [JSConf EU website](http://2013.jsconf.eu/speakers/pete-hunt-react-rethinking-best-practices.html), but in the meantime, here are Pete's slides:
|
||||
|
||||
<figure><iframe src="http://www.slideshare.net/slideshow/embed_code/26589373" width="550" height="450" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen></iframe></figure>
|
||||
|
||||
|
||||
## Pump - Clojure bindings for React
|
||||
|
||||
[Alexander Solovyov](http://solovyov.net/) has been working on React bindings for ClojureScript. This is really exciting as it is using "native" ClojureScript data structures.
|
||||
|
||||
```ruby
|
||||
(ns your.app
|
||||
(:require-macros [pump.def-macros :refer [defr]])
|
||||
(:require [pump.core]))
|
||||
|
||||
(defr Component
|
||||
:get-initial-state #(identity {:some-value ""})
|
||||
|
||||
[component props state]
|
||||
|
||||
[:div {:class-name "test"} "hello"])
|
||||
```
|
||||
|
||||
[Check it out on GitHub...](https://github.com/piranha/pump)
|
||||
|
||||
|
||||
## JSXHint
|
||||
|
||||
[Todd Kennedy](http://blog.selfassembled.org/) working at [Condé Nast](http://www.condenast.com/) implemented a wrapper on-top of [JSHint](http://www.jshint.com/) that first converts JSX files to JS.
|
||||
|
||||
> A wrapper around JSHint to allow linting of files containg JSX syntax. Accepts glob patterns. Respects your local .jshintrc file and .gitignore to filter your glob patterns.
|
||||
>
|
||||
> ```
|
||||
npm install -g jsxhint
|
||||
```
|
||||
>
|
||||
> [Check it out on GitHub...](https://github.com/CondeNast/JSXHint)
|
||||
|
||||
|
||||
## Turbo React
|
||||
|
||||
[Ross Allen](https://twitter.com/ssorallen) working at [Mesosphere](http://mesosphere.io/) combined [Turbolinks](https://github.com/rails/turbolinks/), a library used by Ruby on Rails to speed up page transition, and React.
|
||||
|
||||
> "Re-request this page" is just a link to the current page. When you click it, Turbolinks intercepts the GET request and fetchs the full page via XHR.
|
||||
>
|
||||
> The panel is rendered with a random panel- class on each request, and the progress bar gets a random widthX class.
|
||||
>
|
||||
> With Turbolinks alone, the entire <body> would be replaced, and transitions would not happen. In this little demo though, React adds and removes classes and text, and the attribute changes are animated with CSS transitions. The DOM is otherwise left intact.
|
||||
><figure>[](https://turbo-react.herokuapp.com/)</figure>
|
||||
>
|
||||
> [Check out the demo...](https://turbo-react.herokuapp.com/)
|
||||
|
||||
|
||||
## Reactive Table
|
||||
|
||||
[Stoyan Stefanov](http://www.phpied.com/) continues his series of blog posts about React. This one is an introduction tutorial on rendering a simple table with React.
|
||||
|
||||
> React is all about components. So let's build one.
|
||||
>
|
||||
> Let's call it Table (to avoid any confusion what the component is about).
|
||||
>
|
||||
> ```javascript
|
||||
var Table = React.createClass({
|
||||
/*stuff goeth here*/
|
||||
});
|
||||
```
|
||||
>
|
||||
> You see that React components are defined using a regular JS object. Some properties and methods of the object such as render() have special meanings, the rest is upforgrabs.
|
||||
>
|
||||
> [Read the full article...](http://www.phpied.com/reactive-table/)
|
||||
|
||||
143
docs/_posts/2013-11-05-thinking-in-react.md
Normal file
143
docs/_posts/2013-11-05-thinking-in-react.md
Normal file
@@ -0,0 +1,143 @@
|
||||
---
|
||||
title: "Thinking in React"
|
||||
layout: post
|
||||
author: Pete Hunt
|
||||
---
|
||||
|
||||
React is, in my opinion, the premier way to build big, fast Web apps with JavaScript. It's scaled very well for us at Facebook and Instagram.
|
||||
|
||||
One of the many great parts of React is how it makes you think about apps as you build them. In this post I'll walk you through the thought process of building a searchable product data table using React.
|
||||
|
||||
## Start with a mock
|
||||
|
||||
Imagine that we already have a JSON API and a mock from our designer. Our designer apparently isn't very good because the mock looks like this:
|
||||
|
||||

|
||||
|
||||
Our JSON API returns some data that looks like this:
|
||||
|
||||
```
|
||||
[
|
||||
{category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"},
|
||||
{category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"},
|
||||
{category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"},
|
||||
{category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"},
|
||||
{category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"},
|
||||
{category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"}
|
||||
];
|
||||
```
|
||||
|
||||
## Step 1: break the UI into a component hierarchy
|
||||
|
||||
The first thing you'll want to do is to draw boxes around every component (and subcomponent) in the mock and give them all names. If you're working with a designer they may have already done this, so go talk to them! Their Photoshop layer names may end up being the names of your React components!
|
||||
|
||||
But how do you know what should be its own component? Just use the same techniques for deciding if you should create a new function or object. One such technique is the [single responsibility principle](http://en.wikipedia.org/wiki/Single_responsibility_principle), that is, a component should ideally only do one thing. If it ends up growing it should be decomposed into smaller subcomponents.
|
||||
|
||||
Since you're often displaying a JSON data model to a user, you'll find that if your model was built correctly your UI (and therefore your component structure) will map nicely onto it. That's because user interfaces and data models tend to adhere to the same *information architecture* which means the work of separating your UI into components is often trivial. Just break it up into components that represent exactly one piece of your data model.
|
||||
|
||||

|
||||
|
||||
You'll see here that we have five components in our simple app. I've italicized the data each component represents.
|
||||
|
||||
1. **`FilterableProductTable` (orange):** contains the entirety of the example
|
||||
2. **`SearchBar` (blue):** receives all *user input*
|
||||
3. **`ProductTable` (green):** displays and filters the *data collection* based on *user input*
|
||||
4. **`ProductCategoryRow` (turquoise):** displays a heading for each *category*
|
||||
5. **`ProductRow` (red):** displays a row for each *product*
|
||||
|
||||
If you look at `ProductTable` you'll see that the table header (containing the "Name" and "Price" labels) isn't its own component. This is a matter of preference and there's an argument to be made either way. For this example I left it as part of `ProductTable` because it is part of rendering the *data collection* which is `ProductTable`'s responsibility. However if this header grows to be complex (i.e. if we were to add affordances for sorting) it would certainly make sense to make this its own `ProductTableHeader` component.
|
||||
|
||||
Now that we've identified the components in our mock, let's arrange them into a hierarchy. This is easy. Components that appear within another component in the mock should appear as a child in the hierarchy:
|
||||
|
||||
* `FilterableProductTable`
|
||||
* `SearchBar`
|
||||
* `ProductTable`
|
||||
* `ProductCategoryRow`
|
||||
* `ProductRow`
|
||||
|
||||
## Step 2: Build a static version in React
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/6wQMG/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
Now that you have your component hierarchy it's time to start implementing your app. The easiest way is to build a version that takes your data model and renders the UI but has no interactivity. It's easiest to decouple these processes because building a static version requires a lot of typing and no thinking, and adding interactivity requires a lot of thinking and not a lot of typing. We'll see why.
|
||||
|
||||
To build a static version of your app that renders your data model you'll want to build components that reuse other components and pass data using *props*. *props* are a way of passing data from parent to child. If you're familiar with the concept of *state*, **don't use state at all** to build this static version. State is reserved only for interactivity, that is, data that changes over time. Since this is a static version of the app you don't need it.
|
||||
|
||||
You can build top-down or bottom-up. That is, you can either start with building the components higher up in the hierarchy (i.e. starting with `FilterableProductTable`) or with the ones lower in it (`ProductRow`). In simpler examples it's usually easier to go top-down and on larger projects it's easier to go bottom-up and write tests as you build.
|
||||
|
||||
At the end of this step you'll have a library of reusable components that render your data model. The components will only have `render()` methods since this is a static version of your app. The component at the top of the hierarchy (`FilterableProductTable`) will take your data model as a prop. If you make a change to your underlying data model and call `renderComponent()` again the UI will be updated. It's easy to see how your UI is updated and where to make changes since there's nothing complicated going on since React's **one-way data flow** (also called *one-way binding*) keeps everything modular, easy to reason about, and fast.
|
||||
|
||||
Simply refer to the [React docs](http://facebook.github.io/react/docs/) if you need help executing this step.
|
||||
|
||||
### A brief interlude: props vs state
|
||||
|
||||
There are two types of "model" data in React: props and state. It's important to understand the distinction between the two; skim [the official React docs](http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html) if you aren't sure what the difference is.
|
||||
|
||||
## Step 3: Identify the minimal (but complete) representation of UI state
|
||||
|
||||
To make your UI interactive you need to be able to trigger changes to your underlying data model. React makes this easy with **state**.
|
||||
|
||||
To build your app correctly you first need to think of the minimal set of mutable state that your app needs. The key here is DRY: *Don't Repeat Yourself*. Figure out what the absolute minimal representation of the state of your application needs to be and compute everything else you need on-demand. For example, if you're building a TODO list, just keep an array of the TODO items around; don't keep a separate state variable for the count. Instead, when you want to render the TODO count simply take the length of the TODO items array.
|
||||
|
||||
Think of all of the pieces of data in our example application. We have:
|
||||
|
||||
* The original list of products
|
||||
* The search text the user has entered
|
||||
* The value of the checkbox
|
||||
* The filtered list of products
|
||||
|
||||
Let's go through each one and figure out which one is state. Simply ask three questions about each piece of data:
|
||||
|
||||
1. Is it passed in from a parent via props? If so, it probably isn't state.
|
||||
2. Does it change over time? If not, it probably isn't state.
|
||||
3. Can you compute it based on any other state or props in your component? If so, it's not state.
|
||||
|
||||
The original list of products is passed in as props, so that's not state. The search text and the checkbox seem to be state since they change over time and can't be computed from anything. And finally, the filtered list of products isn't state because it can be computed by combining the original list of products with the search text and value of the checkbox.
|
||||
|
||||
So finally, our state is:
|
||||
|
||||
* The search text the user has entered
|
||||
* The value of the checkbox
|
||||
|
||||
## Step 4: Identify where your state should live
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/QvHnx/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
OK, so we've identified what the minimal set of app state is. Next we need to identify which component mutates, or *owns*, this state.
|
||||
|
||||
Remember: React is all about one-way data flow down the component hierarchy. It may not be immediately clear which component should own what state. **This is often the most challenging part for newcomers to understand,** so follow these steps to figure it out:
|
||||
|
||||
For each piece of state in your application:
|
||||
|
||||
* Identify every component that renders something based on that state.
|
||||
* Find a common owner component (a single component above all the components that need the state in the hierarchy).
|
||||
* Either the common owner or another component higher up in the hierarchy should own the state.
|
||||
* If you can't find a component where it makes sense to own the state, create a new component simply for holding the state and add it somewhere in the hierarchy above the common owner component.
|
||||
|
||||
Let's run through this strategy for our application:
|
||||
|
||||
* `ProductTable` needs to filter the product list based on state and `SearchBar` needs to display the search text and checked state.
|
||||
* The common owner component is `FilterableProductTable`.
|
||||
* It conceptually makes sense for the filter text and checked value to live in `FilterableProductTable`
|
||||
|
||||
Cool, so we've decided that our state lives in `FilterableProductTable`. First, add a `getInitialState()` method to `FilterableProductTable` that returns `{filterText: '', inStockOnly: false}` to reflect the initial state of your application. Then pass `filterText` and `inStockOnly` to `ProductTable` and `SearchBar` as a prop. Finally, use these props to filter the rows in `ProductTable` and set the values of the form fields in `SearchBar`.
|
||||
|
||||
You can start seeing how your application will behave: set `filterText` to `"ball"` and refresh your app. You'll see the data table is updated correctly.
|
||||
|
||||
## Step 5: Add inverse data flow
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/3Vs3Q/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
So far we've built an app that renders correctly as a function of props and state flowing down the hierarchy. Now it's time to support data flowing the other way: the form components deep in the hierarchy need to update the state in `FilterableProductTable`.
|
||||
|
||||
React makes this data flow explicit to make it easy to understand how your program works, but it does require a little more typing than traditional two-way data binding. React provides an add-on called `ReactLink` to make this pattern as convenient as two-way binding, but for the purpose of this post we'll keep everything explicit.
|
||||
|
||||
If you try to type or check the box in the current version of the example you'll see that React ignores your input. This is intentional, as we've set the `value` prop of the `input` to always be equal to the `state` passed in from `FilterableProductTable`.
|
||||
|
||||
Let's think about what we want to happen. We want to make sure that whenever the user changes the form we update the state to reflect the user input. Since components should only update their own state, `FilterableProductTable` will pass a callback to `SearchBar` that will fire whenever the state should be updated. We can use the `onChange` event on the inputs to be notified of it. And the callback passed by `FilterableProductTable` will call `setState()` and the app will be updated.
|
||||
|
||||
Though this sounds like a lot it's really just a few lines of code. And it's really explicit how your data is flowing throughout the app.
|
||||
|
||||
## And that's it
|
||||
|
||||
Hopefully this gives you an idea of how to think about building components and applications with React. While it may be a little more typing than you're used to, remember that code is read far more than it's written, and it's extremely easy to read this modular, explicit code. As you start to build large libraries of components you'll appreciate this explicitness and modularity, and with code reuse your lines of code will start to shrink :)
|
||||
125
docs/_posts/2013-11-06-community-roundup-10.md
Normal file
125
docs/_posts/2013-11-06-community-roundup-10.md
Normal file
@@ -0,0 +1,125 @@
|
||||
---
|
||||
title: "Community Round-up #10"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
This is the 10th round-up already and React has come quite far since it was open sourced. Almost all new web projects at Khan Academy, Facebook, and Instagram are being developed using React. React has been deployed in a variety of contexts: a Chrome extension, a Windows 8 application, mobile websites, and desktop websites supporting Internet Explorer 8! Language-wise, React is not only being used within JavaScript but also CoffeeScript and ClojureScript.
|
||||
|
||||
The best part is that no drastic changes have been required to support all those use cases. Most of the efforts were targeted at polishing edge cases, performance improvements, and documentation.
|
||||
|
||||
## Khan Academy - Officially moving to React
|
||||
|
||||
[Joel Burget](http://joelburget.com/) announced at Hack Reactor that new front-end code at Khan Academy should be written in React!
|
||||
|
||||
> How did we get the rest of the team to adopt React? Using interns as an attack vector! Most full-time devs had already been working on their existing projects for a while and weren't looking to try something new at the time, but our class of summer interns was just arriving. For whatever reason, a lot of them decided to try React for their projects. Then mentors became exposed through code reviews or otherwise touching the new code. In this way React knowledge diffused to almost the whole team over the summer.
|
||||
>
|
||||
> Since the first React checkin on June 5, we've somehow managed to accumulate 23500 lines of jsx (React-flavored js) code. Which is terrifying in a way - that's a lot of code - but also really exciting that it was picked up so quickly.
|
||||
>
|
||||
> We held three meetings about how we should proceed with React. At the first two we decided to continue experimenting with React and deferred a final decision on whether to adopt it. At the third we adopted the policy that new code should be written in React.
|
||||
>
|
||||
> I'm excited that we were able to start nudging code quality forward. However, we still have a lot of work to do! One of the selling points of this transition is adopting a uniform frontend style. We're trying to upgrade all the code from (really old) pure jQuery and (regular old) Backbone views / Handlebars to shiny React. At the moment all we've done is introduce more fragmentation. We won't be gratuitously updating working code (if it ain't broke, don't fix it), but are seeking out parts of the codebase where we can shoot two birds with one stone by rewriting in React while fixing bugs or adding functionality.
|
||||
>
|
||||
> [Read the full article](http://joelburget.com/backbone-to-react/)
|
||||
|
||||
|
||||
## React: Rethinking best practices
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/)'s talk at JSConf EU 2013 is now available in video.
|
||||
|
||||
<figure><iframe width="600" height="370" src="//www.youtube.com/embed/x7cQ3mrcKaY" frameborder="0" allowfullscreen></iframe></figure>
|
||||
|
||||
|
||||
## Server-side React with PHP
|
||||
|
||||
[Stoyan Stefanov](http://www.phpied.com/)'s series of articles on React has two new entries on how to execute React on the server to generate the initial page load.
|
||||
|
||||
> This post is an initial hack to have React components render server-side in PHP.
|
||||
>
|
||||
> - Problem: Build web UIs
|
||||
> - Solution: React
|
||||
> - Problem: UI built in JS is anti-SEO (assuming search engines are still noscript) and bad for perceived performance (blank page till JS arrives)
|
||||
> - Solution: [React page](https://github.com/facebook/react-page) to render the first view
|
||||
> - Problem: Can't host node.js apps / I have tons of PHP code
|
||||
> - Solution: Use PHP then!
|
||||
>
|
||||
> [**Read part 1 ...**](http://www.phpied.com/server-side-react-with-php/)
|
||||
>
|
||||
> [**Read part 2 ...**](http://www.phpied.com/server-side-react-with-php-part-2/)
|
||||
>
|
||||
> Rendered markup on the server:
|
||||
> <figure>[](http://www.phpied.com/server-side-react-with-php-part-2/)</figure>
|
||||
|
||||
|
||||
## TodoMVC Benchmarks
|
||||
|
||||
Webkit has a [TodoMVC Benchmark](https://github.com/WebKit/webkit/tree/master/PerformanceTests/DoYouEvenBench) that compares different frameworks. They recently included React and here are the results (average of 10 runs in Chrome 30):
|
||||
|
||||
- **AngularJS:** 4043ms
|
||||
- **AngularJSPerf:** 3227ms
|
||||
- **BackboneJS:** 1874ms
|
||||
- **EmberJS:** 6822ms
|
||||
- **jQuery:** 14628ms
|
||||
- **React:** 2864ms
|
||||
- **VanillaJS:** 5567ms
|
||||
|
||||
[Try it yourself!](http://www.petehunt.net/react/tastejs/benchmark.html)
|
||||
|
||||
Please don't take those numbers too seriously, they only reflect one very specific use case and are testing code that wasn't written with performance in mind.
|
||||
|
||||
Even though React scores as one of the fastest frameworks in the benchmark, the React code is simple and idiomatic. The only performance tweak used is the following function:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* This is a completely optional performance enhancement that you can implement
|
||||
* on any React component. If you were to delete this method the app would still
|
||||
* work correctly (and still be very performant!), we just use it as an example
|
||||
* of how little code it takes to get an order of magnitude performance improvement.
|
||||
*/
|
||||
shouldComponentUpdate: function (nextProps, nextState) {
|
||||
return (
|
||||
nextProps.todo.id !== this.props.todo.id ||
|
||||
nextProps.todo !== this.props.todo ||
|
||||
nextProps.editing !== this.props.editing ||
|
||||
nextState.editText !== this.state.editText
|
||||
);
|
||||
},
|
||||
```
|
||||
|
||||
By default, React "re-renders" all the components when anything changes. This is usually fast enough that you don't need to care. However, you can provide a function that can tell whether there will be any change based on the previous and next states and props. If it is faster than re-rendering the component, then you get a performance improvement.
|
||||
|
||||
The fact that you can control when components are rendered is a very important characteristic of React as it gives you control over its performance. We are going to talk more about performance in the future, stay tuned.
|
||||
|
||||
## Guess the filter
|
||||
|
||||
[Connor McSheffrey](http://conr.me) implemented a small game using React. The goal is to guess which filter has been used to create the Instagram photo.
|
||||
<figure>[](http://guessthefilter.com/)</figure>
|
||||
|
||||
|
||||
## React vs FruitMachine
|
||||
|
||||
[Andrew Betts](http://trib.tv/), director of the [Financial Times Labs](http://labs.ft.com/), posted an article comparing [FruitMachine](https://github.com/ftlabs/fruitmachine) and React.
|
||||
|
||||
> Eerily similar, no? Maybe Facebook was inspired by Fruit Machine (after all, we got there first), but more likely, it just shows that this is a pretty decent way to solve the problem, and great minds think alike. We're graduating to a third phase in the evolution of web best practice - from intermingling of markup, style and behaviour, through a phase in which those concerns became ever more separated and encapsulated, and finally to a model where we can do that separation at a component level. Developments like Web Components show the direction the web community is moving, and frameworks like React and Fruit Machine are in fact not a lot more than polyfills for that promised behaviour to come.
|
||||
>
|
||||
> [Read the full article...](http://labs.ft.com/2013/10/client-side-layout-engines-react-vs-fruitmachine/)
|
||||
|
||||
Even though we weren't inspired by FruitMachine (React has been used in production since before FruitMachine was open sourced), it's great to see similar technologies emerging and becoming popular.
|
||||
|
||||
## React Brunch
|
||||
|
||||
[Matthew McCray](http://elucidata.net/) implemented [react-brunch](https://npmjs.org/package/react-brunch), a JSX compilation step for [Brunch](http://brunch.io/).
|
||||
|
||||
> Adds React support to brunch by automatically compiling `*.jsx` files.
|
||||
>
|
||||
> You can configure react-brunch to automatically insert a react header (`/** @jsx React.DOM */`) into all `*.jsx` files. Disabled by default.
|
||||
>
|
||||
> Install the plugin via npm with `npm install --save react-brunch`.
|
||||
>
|
||||
> [Read more...](https://npmjs.org/package/react-brunch)
|
||||
|
||||
## Random Tweet
|
||||
|
||||
I'm going to start adding a tweet at the end of each round-up. We'll start with this one:
|
||||
|
||||
<blockquote class="twitter-tweet"><p>This weekend <a href="https://twitter.com/search?q=%23angular&src=hash">#angular</a> died for me. Meet new king <a href="https://twitter.com/search?q=%23reactjs&src=hash">#reactjs</a></p>— Eldar Djafarov ッ (@edjafarov) <a href="https://twitter.com/edjafarov/statuses/397033796710961152">November 3, 2013</a></blockquote>
|
||||
92
docs/_posts/2013-11-18-community-roundup-11.md
Normal file
92
docs/_posts/2013-11-18-community-roundup-11.md
Normal file
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: "Community Round-up #11"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
This round-up is the proof that React has taken off from its Facebook's root: it features three in-depth presentations of React done by external people. This is awesome, keep them coming!
|
||||
|
||||
## Super VanJS 2013 Talk
|
||||
|
||||
[Steve Luscher](https://github.com/steveluscher) working at [LeanPub](https://leanpub.com/) made a 30 min talk at [Super VanJS](https://twitter.com/vanjs). He does a remarkable job at explaining why React is so fast with very exciting demos using the HTML5 Audio API.
|
||||
|
||||
<figure><iframe width="600" height="338" src="//www.youtube.com/embed/1OeXsL5mr4g" frameborder="0" allowfullscreen></iframe></figure>
|
||||
|
||||
|
||||
## React Tips
|
||||
|
||||
[Connor McSheffrey](http://connormcsheffrey.com/) and [Cheng Lou](https://github.com/chenglou) added a new section to the documentation. It's a list of small tips that you will probably find useful while working on React. Since each article is very small and focused, we [encourage you to contribute](http://facebook.github.io/react/tips/introduction.html)!
|
||||
|
||||
- [Inline Styles](http://facebook.github.io/react/tips/inline-styles.html)
|
||||
- [If-Else in JSX](http://facebook.github.io/react/tips/if-else-in-JSX.html)
|
||||
- [Self-Closing Tag](http://facebook.github.io/react/tips/self-closing-tag.html)
|
||||
- [Maximum Number of JSX Root Nodes](http://facebook.github.io/react/tips/maximum-number-of-jsx-root-nodes.html)
|
||||
- [Shorthand for Specifying Pixel Values in style props](http://facebook.github.io/react/tips/style-props-value-px.html)
|
||||
- [Type of the Children props](http://facebook.github.io/react/tips/children-props-type.html)
|
||||
- [Value of null for Controlled Input](http://facebook.github.io/react/tips/controlled-input-null-value.html)
|
||||
- [`componentWillReceiveProps` Not Triggered After Mounting](http://facebook.github.io/react/tips/componentWillReceiveProps-not-triggered-after-mounting.html)
|
||||
- [Props in getInitialState Is an Anti-Pattern](http://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html)
|
||||
- [DOM Event Listeners in a Component](http://facebook.github.io/react/tips/dom-event-listeners.html)
|
||||
- [Load Initial Data via AJAX](http://facebook.github.io/react/tips/initial-ajax.html)
|
||||
- [False in JSX](http://facebook.github.io/react/tips/false-in-jsx.html)
|
||||
|
||||
|
||||
## Intro to the React Framework
|
||||
|
||||
[Pavan Podila](http://blog.pixelingene.com/) wrote an in-depth introduction to React on TutsPlus. This is definitively worth reading.
|
||||
|
||||
> Within a component-tree, data should always flow down. A parent-component should set the props of a child-component to pass any data from the parent to the child. This is termed as the Owner-Owned pair. On the other hand user-events (mouse, keyboard, touches) will always bubble up from the child all the way to the root component, unless handled in between.
|
||||
<figure>[](http://dev.tutsplus.com/tutorials/intro-to-the-react-framework--net-35660)</figure>
|
||||
>
|
||||
> [Read the full article ...](http://dev.tutsplus.com/tutorials/intro-to-the-react-framework--net-35660)
|
||||
|
||||
|
||||
## 140-characters textarea
|
||||
|
||||
[Brian Kim](https://github.com/brainkim) wrote a small textarea component that gradually turns red as you reach the 140-characters limit. Because he only changes the background color, React is smart enough not to mess with the text selection.
|
||||
|
||||
<p data-height="178" data-theme-id="0" data-slug-hash="FECGb" data-user="brainkim" data-default-tab="result" class='codepen'>See the Pen <a href='http://codepen.io/brainkim/pen/FECGb'>FECGb</a> by Brian Kim (<a href='http://codepen.io/brainkim'>@brainkim</a>) on <a href='http://codepen.io'>CodePen</a></p>
|
||||
<script async src="//codepen.io/assets/embed/ei.js"></script>
|
||||
|
||||
|
||||
## Genesis Skeleton
|
||||
|
||||
[Eric Clemmons](http://ericclemmons.github.io/) is working on a "Modern, opinionated, full-stack starter kit for rapid, streamlined application development". The version 0.4.0 has just been released and has first-class support for React.
|
||||
<figure>[](http://genesis-skeleton.com/)</figure>
|
||||
|
||||
|
||||
## AgFlow Talk
|
||||
|
||||
[Robert Zaremba](http://rz.scale-it.pl/) working on [AgFlow](http://www.agflow.com/) recently talked in Poland about React.
|
||||
|
||||
> In a nutshell, I presented why we chose React among other available options (ember.js, angular, backbone ...) in AgFlow, where I’m leading an application development.
|
||||
>
|
||||
> During the talk a wanted to highlight that React is not about implementing a Model, but a way to construct visible components with some state. React is simple. It is super simple, you can learn it in 1h. On the other hand what is model? Which functionality it should provide? React does one thing and does it the best (for me)!
|
||||
>
|
||||
> [Read the full article...](http://rz.scale-it.pl/2013/10/20/frontend_components_in_react.html)
|
||||
|
||||
<figure><iframe src="https://docs.google.com/presentation/d/1JSFbjCuuexwOHCeHWBMNRIJdyfD2Z0ZQwX65WOWkfaI/embed?start=false" frameborder="0" width="600" height="468" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"> </iframe></figure>
|
||||
|
||||
|
||||
## JSX
|
||||
|
||||
[Todd Kennedy](http://tck.io/) working at Condé Nast wrote [JSXHint](https://github.com/CondeNast/JSXHint) and explains in a blog post his perspective on JSX.
|
||||
|
||||
> Lets start with the elephant in the room: JSX?
|
||||
> Is this some sort of template language? Specifically no. This might have been the first big stumbling block. What looks like to be a templating language is actually an in-line DSL that gets transpiled directly into JavaScript by the JSX transpiler.
|
||||
>
|
||||
> Creating elements in memory is quick -- copying those elements into the DOM is where the slowness occurs. This is due to a variety of issues, most namely reflow/paint. Changing the items in the DOM causes the browser to re-paint the display, apply styles, etc. We want to keep those operations to an absolute minimum, especially if we're dealing with something that needs to update the DOM frequently.
|
||||
>
|
||||
> [Read the full article...](http://tck.io/posts/jsxhint_and_react.html)
|
||||
|
||||
|
||||
## Photo Gallery
|
||||
|
||||
[Maykel Loomans](http://miekd.com/), designer at Instagram, wrote a gallery for photos he shot using React.
|
||||
<figure>[](http://photos.miekd.com/xoxo2013/)</figure>
|
||||
|
||||
|
||||
## Random Tweet
|
||||
|
||||
<img src="/react/img/blog/steve_reverse.gif" style="float: right;" />
|
||||
<div style="width: 320px;"><blockquote class="twitter-tweet"><p>I think this reversed gif of Steve Urkel best describes my changing emotions towards the React Lib <a href="http://t.co/JoX0XqSXX3">http://t.co/JoX0XqSXX3</a></p>— Ryan Seddon (@ryanseddon) <a href="https://twitter.com/ryanseddon/statuses/398572848802852864">November 7, 2013</a></blockquote></div>
|
||||
23
docs/_posts/2013-12-18-react-v0.5.2-v0.4.2.md
Normal file
23
docs/_posts/2013-12-18-react-v0.5.2-v0.4.2.md
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
title: "React v0.5.2, v0.4.2"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
Today we're releasing an update to address a potential XSS vulnerability that can arise when using user data as a `key`. Typically "safe" data is used for a `key`, for example, an id from your database, or a unique hash. However there are cases where it may be reasonable to use user generated content. A carefully crafted piece of content could result in arbitrary JS execution. While we make a very concerted effort to ensure all text is escaped before inserting it into the DOM, we missed one case. Immediately following the discovery of this vulnerability, we performed an audit to ensure we this was the only such vulnerability.
|
||||
|
||||
This only affects v0.5.x and v0.4.x. Versions in the 0.3.x family are unaffected.
|
||||
|
||||
Updated versions are available for immediate download via npm, bower, and on our [download page][download].
|
||||
|
||||
We take security very seriously at Facebook. For most of our products, users don't need to know that a security issue has been fixed. But with libraries like React, we need to make sure developers using React have access to fixes to keep their users safe.
|
||||
|
||||
While we've encouraged responsible disclosure as part of [Facebook's whitehat bounty program][bounty] since we launched, we don't have a good process for notifying our users. Hopefully we don't need to use it, but moving forward we'll set up a little bit more process to ensure the safety of our users. Ember.js has [an excellent policy][ember] which we may use as our model.
|
||||
|
||||
You can learn more about the vulnerability discussed here: [CVE-2013-7035][cve].
|
||||
|
||||
[download]: http://facebook.github.io/react/downloads.html
|
||||
[bounty]: https://www.facebook.com/whitehat/
|
||||
[ember]: http://emberjs.com/security/
|
||||
[cve]: https://groups.google.com/forum/#!topic/reactjs/OIqxlB2aGfU
|
||||
|
||||
48
docs/_posts/2013-12-19-react-v0.8.0.md
Normal file
48
docs/_posts/2013-12-19-react-v0.8.0.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
title: "React v0.8"
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
I'll start by answering the obvious question:
|
||||
|
||||
> What happened to 0.6 and 0.7?
|
||||
|
||||
It's become increasingly obvious since our launch in May that people want to use React on the server. With the server-side rendering abilities, that's a perfect fit. However using the same copy of React on the server and then packaging it up for the client is surprisingly a harder problem. People have been using our `react-tools` module which includes React, but when browserifying that ends up packaging all of `esprima` and some other dependencies that aren't needed on the client. So we wanted to make this whole experience better.
|
||||
|
||||
We talked with [Jeff Barczewski][jeff] who was the owner of the `react` module on npm. He was kind enough to transition ownership to us and release his package under a different name: `autoflow`. I encourage you to [check it out][autoflow] if you're writing a lot of asynchronous code. In order to not break all of `react`'s current users of 0.7.x, we decided to bump our version to 0.8 and skip the issue entirely. We're also including a warning if you use our `react` module like you would use the previous package.
|
||||
|
||||
In order to make the transition to 0.8 for our current users as painless as possible, we decided to make 0.8 primarily a bug fix release on top of 0.5. No public APIs were changed (even if they were already marked as deprecated). We haven't added any of the new features we have in master, though we did take the opportunity to pull in some improvements to internals.
|
||||
|
||||
We hope that by releasing `react` on npm, we will enable a new set of uses that have been otherwise difficult. All feedback is welcome!
|
||||
|
||||
|
||||
## Changelog
|
||||
|
||||
### React
|
||||
|
||||
* Added support for more attributes:
|
||||
* `rows` & `cols` for `<textarea>`
|
||||
* `defer` & `async` for `<script>`
|
||||
* `loop` for `<audio>` & `<video>`
|
||||
* `autoCorrect` for form fields (a non-standard attribute only supported by mobile WebKit)
|
||||
* Improved error messages
|
||||
* Fixed Selection events in IE11
|
||||
* Added `onContextMenu` events
|
||||
|
||||
### React with Addons
|
||||
|
||||
* Fixed bugs with TransitionGroup when children were undefined
|
||||
* Added support for `onTransition`
|
||||
|
||||
### react-tools
|
||||
|
||||
* Upgraded `jstransform` and `esprima-fb`
|
||||
|
||||
### JSXTransformer
|
||||
|
||||
* Added support for use in IE8
|
||||
* Upgraded browserify, which reduced file size by ~65KB (16KB gzipped)
|
||||
|
||||
[jeff]: https://github.com/jeffbski
|
||||
[autoflow]: https://github.com/jeffbski/autoflow
|
||||
105
docs/_posts/2013-12-23-community-roundup-12.md
Normal file
105
docs/_posts/2013-12-23-community-roundup-12.md
Normal file
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: "Community Round-up #12"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
React got featured on the front-page of Hacker News thanks to the Om library. If you try it out for the first time, take a look at the [docs](/react/docs/getting-started.html) and do not hesitate to ask questions on the [Google Group](http://groups.google.com/group/reactjs), [IRC](irc://chat.freenode.net/reactjs) or [Stack Overflow](http://stackoverflow.com/questions/tagged/reactjs). We are trying our best to help you out!
|
||||
|
||||
## The Future of Javascript MVC
|
||||
|
||||
[David Nolen](http://swannodette.github.io/) announced Om, a thin wrapper on-top of React in ClojureScript. It stands out by only using immutable data structures. This unlocks the ability to write a very efficient [shouldComponentUpdate](http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate) and get huge performance improvements on some tasks.
|
||||
|
||||
> We've known this for some time over here in the ClojureScript corner of the world - all of our collections are immutable and modeled directly on the original Clojure versions written in Java. Modern JavaScript engines have now been tuned to the point that it's no longer uncommon to see collection performance within 2.5X of the Java Virtual Machine.
|
||||
>
|
||||
> Wait, wait, wait. What does the performance of persistent data structures have to do with the future of JavaScript MVCs?
|
||||
>
|
||||
> A whole lot.
|
||||
> <figure>[](http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/)</figure>
|
||||
>
|
||||
> [Read the full article...](http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/)
|
||||
|
||||
|
||||
|
||||
## Scroll Position with React
|
||||
|
||||
Managing the scroll position when new content is inserted is usually very tricky to get right. [Vjeux](http://blog.vjeux.com/) discovered that [componentWillUpdate](http://facebook.github.io/react/docs/component-specs.html#updating-componentwillupdate) and [componentDidUpdate](http://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate) were triggered exactly at the right time to manage the scroll position.
|
||||
|
||||
> We can check the scroll position before the component has updated with componentWillUpdate and scroll if necessary at componentDidUpdate
|
||||
>
|
||||
> ```
|
||||
componentWillUpdate: function() {
|
||||
var node = this.getDOMNode();
|
||||
this.shouldScrollBottom =
|
||||
(node.scrollTop + node.offsetHeight) === node.scrollHeight;
|
||||
},
|
||||
componentDidUpdate: function() {
|
||||
if (this.shouldScrollBottom) {
|
||||
var node = this.getDOMNode();
|
||||
node.scrollTop = node.scrollHeight
|
||||
}
|
||||
},
|
||||
```
|
||||
>
|
||||
> [Check out the blog article...](http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html)
|
||||
|
||||
|
||||
## Lights Out
|
||||
|
||||
React declarative approach is well suited to write games. [Cheng Lou](https://github.com/chenglou) wrote the famous Lights Out game in React. It's a good example of use of [TransitionGroup](http://facebook.github.io/react/docs/animation.html) to implement animations.
|
||||
<figure>[](http://chenglou.github.io/react-lights-out/)</figure>
|
||||
|
||||
[Try it out!](http://chenglou.github.io/react-lights-out/)
|
||||
|
||||
|
||||
## Reactive Table Bookmarklet
|
||||
|
||||
[Stoyan Stefanov](http://www.phpied.com/) wrote a bookmarklet to process tables on the internet. It adds a little "pop" button that expands to a full-screen view with sorting, editing and export to csv and json.
|
||||
<figure>[](http://www.phpied.com/reactivetable-bookmarklet/)</figure>
|
||||
|
||||
[Check out the blog post...](http://www.phpied.com/reactivetable-bookmarklet/)
|
||||
|
||||
|
||||
## MontageJS Tutorial in React
|
||||
|
||||
[Ross Allen](https://twitter.com/ssorallen) implemented [MontageJS](http://montagejs.org/)'s [Reddit tutorial](http://montagejs.org/docs/tutorial-reddit-client-with-montagejs.html) in React. This is a good opportunity to compare the philosophies of the two libraries.
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/ssorallen/fEsYt/embedded/result,html,js" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
[View the source on JSFiddle...](http://jsfiddle.net/ssorallen/fEsYt/)
|
||||
|
||||
## Writing Good React Components
|
||||
|
||||
[William Högman Rudenmalm](http://blog.whn.se/) wrote an article on how to write good React components. This is full of good advice.
|
||||
|
||||
> The idea of dividing software into smaller parts or components is hardly new - It is the essance of good software. The same principles that apply to software in general apply to building React components. That doesn’t mean that writing good React components is just about applying general rules.
|
||||
>
|
||||
> The web offers a unique set of challenges, which React offers interesting solutions to. First and foremost among these solutions is the what is called the Mock DOM. Rather than having user code interface with the DOM in a direct fashion, as is the case with most DOM manipulation libraries.
|
||||
>
|
||||
> You build a model of how you want the DOM end up like. React then inserts this model into the DOM. This is very useful for updates because React simply compares the model or mock DOM against the actual DOM, and then only updates based on the difference between the two states.
|
||||
>
|
||||
> [Read the full article ...](http://blog.whn.se/post/69621609605/writing-good-react-components)
|
||||
|
||||
|
||||
## Hoodie React TodoMVC
|
||||
|
||||
[Sven Lito](http://svenlito.com/) integrated the React TodoMVC example within an [Hoodie](http://hood.ie/) web app environment. This should let you get started using Hoodie and React.
|
||||
|
||||
```
|
||||
hoodie new todomvc -t "hoodiehq/hoodie-react-todomvc"
|
||||
```
|
||||
|
||||
[Check out on GitHub...](https://github.com/hoodiehq/hoodie-react-todomvc)
|
||||
|
||||
## JSX Compiler
|
||||
|
||||
Ever wanted to have a quick way to see what a JSX tag would be converted to? [Tim Yung](http://www.yungsters.com/) made a page for it.
|
||||
<figure>[](http://facebook.github.io/react/jsx-compiler.html)</figure>
|
||||
|
||||
[Try it out!](http://facebook.github.io/react/jsx-compiler.html)
|
||||
|
||||
|
||||
|
||||
## Random Tweet
|
||||
|
||||
<center><blockquote class="twitter-tweet" lang="en"><p>.<a href="https://twitter.com/jordwalke">@jordwalke</a> lays down some truth <a href="http://t.co/AXAn0UlUe3">http://t.co/AXAn0UlUe3</a>, optimizing your JS application shouldn't force you to rewrite so much code <a href="https://twitter.com/search?q=%23reactjs&src=hash">#reactjs</a></p>— David Nolen (@swannodette) <a href="https://twitter.com/swannodette/statuses/413780079249215488">December 19, 2013</a></blockquote></center>
|
||||
119
docs/_posts/2013-12-30-community-roundup-13.md
Normal file
119
docs/_posts/2013-12-30-community-roundup-13.md
Normal file
@@ -0,0 +1,119 @@
|
||||
---
|
||||
title: "Community Round-up #13"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
Happy holidays! This blog post is a little-late Christmas present for all the React users. Hopefully it will inspire you to write awesome web apps in 2014!
|
||||
|
||||
|
||||
## React Touch
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) wrote three demos showing that React can be used to run 60fps native-like experiences on mobile web. A frosted glass effect, an image gallery with 3d animations and an infinite scroll view.
|
||||
|
||||
<figure><iframe src="//player.vimeo.com/video/79659941" width="220" height="400" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></figure>
|
||||
|
||||
[Try out the demos!](http://petehunt.github.io/react-touch/)
|
||||
|
||||
|
||||
## Introduction to React
|
||||
|
||||
[Stoyan Stefanov](http://www.phpied.com/) talked at Joe Dev On Tech about React. He goes over all the features of the library and ends with a concrete example.
|
||||
|
||||
<figure><iframe width="560" height="315" src="//www.youtube.com/embed/SMMRJif5QW0" frameborder="0" allowfullscreen></iframe></figure>
|
||||
|
||||
|
||||
## JSX: E4X The Good Parts
|
||||
|
||||
JSX is often compared to the now defunct E4X, [Vjeux](http://blog.vjeux.com/) went over all the E4X features and explained how JSX is different and hopefully doesn't repeat the same mistakes.
|
||||
|
||||
> E4X (ECMAScript for XML) is a Javascript syntax extension and a runtime to manipulate XML. It was promoted by Mozilla but failed to become mainstream and is now deprecated. JSX was inspired by E4X. In this article, I'm going to go over all the features of E4X and explain the design decisions behind JSX.
|
||||
>
|
||||
> **Historical Context**
|
||||
>
|
||||
> E4X has been created in 2002 by John Schneider. This was the golden age of XML where it was being used for everything: data, configuration files, code, interfaces (DOM) ... E4X was first implemented inside of Rhino, a Javascript implementation from Mozilla written in Java.
|
||||
>
|
||||
> [Continue reading ...](http://blog.vjeux.com/2013/javascript/jsx-e4x-the-good-parts.html)
|
||||
|
||||
|
||||
## React + Socket.io
|
||||
|
||||
[Geert Pasteels](http://enome.be/nl) made a small experiment with Socket.io. He wrote a very small mixin that synchronizes React state with the server. Just include this mixin to your React component and it is now live!
|
||||
|
||||
```javascript
|
||||
changeHandler: function (data) {
|
||||
if (!_.isEqual(data.state, this.state) && this.path === data.path) {
|
||||
this.setState(data.state);
|
||||
}
|
||||
},
|
||||
componentDidMount: function (root) {
|
||||
this.path = utils.nodePath(root);
|
||||
socket.on('component-change', this.changeHandler);
|
||||
},
|
||||
componentWillUpdate: function (props, state) {
|
||||
socket.emit('component-change', { path: this.path, state: state });
|
||||
},
|
||||
componentWillUnmount: function () {
|
||||
socket.removeListener('component-change', this.change);
|
||||
}
|
||||
```
|
||||
|
||||
[Check it out on GitHub...](https://github.com/Enome/react.io)
|
||||
|
||||
|
||||
## cssobjectify
|
||||
|
||||
[Andrey Popp](http://andreypopp.com/) implemented a source transform that takes a CSS file and converts it to JSON. This integrates pretty nicely with React.
|
||||
|
||||
```javascript
|
||||
/* style.css */
|
||||
MyComponent {
|
||||
font-size: 12px;
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
/* myapp.js */
|
||||
var React = require('react-tools/build/modules/React');
|
||||
var Styles = require('./styles.css');
|
||||
|
||||
var MyComponent = React.createClass({
|
||||
render: function() {
|
||||
return (
|
||||
<div style={Styles.MyComponent}>
|
||||
Hello, world!
|
||||
</div>
|
||||
)
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
[Check it out on GitHub...](https://github.com/andreypopp/cssobjectify)
|
||||
|
||||
|
||||
## ngReact
|
||||
|
||||
[David Chang](http://davidandsuzi.com/) working at [HasOffer](http://www.hasoffers.com/) wanted to speed up his Angular app and replaced Angular primitives by React at different layers. When using React naively it is 67% faster, but when combining it with angular's transclusion it is 450% slower.
|
||||
|
||||
> Rendering this takes 803ms for 10 iterations, hovering around 35 and 55ms for each data reload (that's 67% faster). You'll notice that the first load takes a little longer than successive loads, and the second load REALLY struggles - here, it's 433ms, which is more than half of the total time!
|
||||
> <figure>[](http://davidandsuzi.com/ngreact-react-components-in-angular/)</figure>
|
||||
>
|
||||
> [Read the full article...](http://davidandsuzi.com/ngreact-react-components-in-angular/)
|
||||
|
||||
|
||||
## vim-jsx
|
||||
|
||||
[Max Wang](https://github.com/mxw) made a vim syntax highlighting and indentation plugin for vim.
|
||||
|
||||
> Syntax highlighting and indenting for JSX. JSX is a JavaScript syntax transformer which translates inline XML document fragments into JavaScript objects. It was developed by Facebook alongside React.
|
||||
>
|
||||
> This bundle requires pangloss's [vim-javascript](https://github.com/pangloss/vim-javascript) syntax highlighting.
|
||||
>
|
||||
> Vim support for inline XML in JS is remarkably similar to the same for PHP.
|
||||
>
|
||||
> [View on GitHub...](https://github.com/mxw/vim-jsx)
|
||||
|
||||
|
||||
## Random Tweet
|
||||
|
||||
<center><blockquote class="twitter-tweet" lang="en"><p>I may be starting to get annoying with this, but ReactJS is really exciting. I truly feel the virtual DOM is a game changer.</p>— Eric Florenzano (@ericflo) <a href="https://twitter.com/ericflo/statuses/413842834974732288">December 20, 2013</a></blockquote></center>
|
||||
|
||||
19
docs/_posts/2014-01-02-react-chrome-developer-tools.md
Normal file
19
docs/_posts/2014-01-02-react-chrome-developer-tools.md
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
title: "React Chrome Developer Tools"
|
||||
layout: post
|
||||
author: Sebastian Markbåge
|
||||
---
|
||||
|
||||
With the new year, we thought you'd enjoy some new tools for debugging React code. Today we're releasing the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi), an extension to the Chrome Developer Tools. [Download them from the Chrome Web Store](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi).
|
||||
|
||||
<figure><iframe width="560" height="315" src="//www.youtube.com/embed/Cey7BS6dE0M" frameborder="0" allowfullscreen></iframe></figure>
|
||||
|
||||
You will get a new tab titled "React" in your Chrome DevTools. This tab shows you a list of the root React Components that are rendered on the page as well as the subcomponents that each root renders.
|
||||
|
||||
Selecting a Component in this tab allows you to view and edit its props and state in the panel on the right. In the breadcrumbs at the bottom, you can inspect the selected Component, the Component that created it, the Component that created that one, and so on.
|
||||
|
||||
When you inspect a DOM element using the regular Elements tab, you can switch over to the React tab and the corresponding Component will be automatically selected. The Component will also be automatically selected if you have a breakpoint within its render phase. This allows you to step through the render tree and see how one Component affects another one.
|
||||
<figure>[](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi)</figure>
|
||||
|
||||
We hope these tools will help your team better understand your component hierarchy and track down bugs. We're very excited about this initial launch and appreciate any feedback you may have. As always, we also accept [pull requests on GitHub](https://github.com/facebook/react-devtools).
|
||||
|
||||
92
docs/_posts/2014-01-06-community-roundup-14.md
Normal file
92
docs/_posts/2014-01-06-community-roundup-14.md
Normal file
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: "Community Round-up #14"
|
||||
layout: post
|
||||
author: Vjeux
|
||||
---
|
||||
|
||||
The theme of this first round-up of 2014 is integration. I've tried to assemble a list of articles and projects that use React in various environments.
|
||||
|
||||
## React Baseline
|
||||
|
||||
React is only one-piece of your web application stack. [Mark Lussier](https://github.com/intabulas) shared his baseline stack that uses React along with Grunt, Browserify, Bower, Zepto, Director and Sass. This should help you get started using React for a new project.
|
||||
|
||||
> As I do more projects with ReactJS I started to extract a baseline to use when starting new projects. This is very opinionated and I change my opinion from time to time. This is by no ways perfect and in your opinion most likely wrong :).. which is why I love github
|
||||
>
|
||||
> I encourage you to fork, and make it right and submit a pull request!
|
||||
>
|
||||
> My current opinion is using tools like Grunt, Browserify, Bower and mutiple grunt plugins to get the job done. I also opted for Zepto over jQuery and the Flatiron Project's Director when I need a router. Oh and for the last little bit of tech that makes you mad, I am in the SASS camp when it comes to stylesheets
|
||||
>
|
||||
> [Check it out on GitHub...](https://github.com/intabulas/reactjs-baseline)
|
||||
|
||||
|
||||
## Animal Sounds
|
||||
|
||||
[Josh Duck](http://joshduck.com/) used React in order to build a Windows 8 tablet app. This is a good example of a touch app written in React.
|
||||
<figure>[](http://apps.microsoft.com/windows/en-us/app/baby-play-animal-sounds/9280825c-2ed9-41c0-ba38-aa9a5b890bb9)</figure>
|
||||
|
||||
[Download the app...](http://apps.microsoft.com/windows/en-us/app/baby-play-animal-sounds/9280825c-2ed9-41c0-ba38-aa9a5b890bb9)
|
||||
|
||||
|
||||
## React Rails Tutorial
|
||||
|
||||
[Selem Delul](http://selem.im) bundled the [React Tutorial](http://facebook.github.io/react/docs/tutorial.html) into a rails app. This is a good example on how to get started with a rails project.
|
||||
|
||||
> ```
|
||||
git clone https://github.com/necrodome/react-rails-tutorial
|
||||
cd react-rails-tutorial
|
||||
bundle install
|
||||
rake db:migrate
|
||||
rails s
|
||||
```
|
||||
> Then visit http://localhost:3000/app to see the React application that is explained in the React Tutorial. Try opening multiple tabs!
|
||||
>
|
||||
> [View on GitHub...](https://github.com/necrodome/react-rails-tutorial)
|
||||
|
||||
## Mixing with Backbone
|
||||
|
||||
[Eldar Djafarov](http://eldar.djafarov.com/) implemented a mixin to link Backbone models to React state and a small abstraction to write two-way binding on-top.
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/djkojb/qZf48/13/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
[Check out the blog post...](http://eldar.djafarov.com/2013/11/reactjs-mixing-with-backbone/)
|
||||
|
||||
|
||||
## React Infinite Scroll
|
||||
|
||||
[Guillaume Rivals](https://twitter.com/guillaumervls) implemented an InfiniteScroll component. This is a good example of a React component that has a simple yet powerful API.
|
||||
|
||||
```javascript
|
||||
<InfiniteScroll
|
||||
pageStart={0}
|
||||
loadMore={loadFunc}
|
||||
hasMore={true || false}
|
||||
loader={<div className="loader">Loading ...</div>}>
|
||||
{items} // <-- This is the "stuff" you want to load
|
||||
</InfiniteScroll>
|
||||
```
|
||||
|
||||
[Try it out on GitHub!](https://github.com/guillaumervls/react-infinite-scroll)
|
||||
|
||||
|
||||
## Web Components Style
|
||||
|
||||
[Thomas Aylott](http://subtlegradient.com/) implemented an API that looks like Web Components but using React underneath.
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/SubtleGradient/ue2Aa/embedded/html,js,result" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
|
||||
## React vs Angular
|
||||
|
||||
React is often compared with Angular. [Pete Hunt](http://skulbuny.com/2013/10/31/react-vs-angular/) wrote an opinionated post on the subject.
|
||||
|
||||
> First of all I think it’s important to evaluate technologies on objective rather than subjective features. “It feels nicer” or “it’s cleaner” aren’t valid reasons: performance, modularity, community size and ease of testing / integration with other tools are.
|
||||
>
|
||||
> I’ve done a lot of work benchmarking, building apps, and reading the code of Angular to try to come up with a reasonable comparison between their ways of doing things.
|
||||
>
|
||||
> [Read the full post...](http://skulbuny.com/2013/10/31/react-vs-angular/)
|
||||
|
||||
|
||||
|
||||
## Random Tweet
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>Really intrigued by React.js. I've looked at all JS frameworks, and excepting <a href="https://twitter.com/serenadejs">@serenadejs</a> this is the first one which makes sense to me.</p>— Jonas Nicklas (@jonicklas) <a href="https://twitter.com/jonicklas/statuses/412640708755869696">December 16, 2013</a></blockquote></div>
|
||||
126
docs/_posts/2014-02-05-community-roundup-15.md
Normal file
126
docs/_posts/2014-02-05-community-roundup-15.md
Normal file
@@ -0,0 +1,126 @@
|
||||
---
|
||||
title: "Community Round-up #15"
|
||||
layout: post
|
||||
author: Jonas Gebhardt
|
||||
---
|
||||
|
||||
Interest in React seems to have surged ever since David Nolen ([@swannodette](https://twitter.com/swannodette))'s introduction of [Om](https://github.com/swannodette/om) in his post ["The Future of Javascript MVC Frameworks"](http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/).
|
||||
|
||||
In this React Community Round-up, we are taking a closer look at React from a functional programming perspective.
|
||||
|
||||
## "React: Another Level of Indirection"
|
||||
To start things off, Eric Normand ([@ericnormand](https://twitter.com/ericnormand)) of [LispCast](http://lispcast.com) makes the case for [React from a general functional programming standpoint](http://www.lispcast.com/react-another-level-of-indirection) and explains how React's "Virtual DOM provides the last piece of the Web Frontend Puzzle for ClojureScript".
|
||||
|
||||
> The Virtual DOM is an indirection mechanism that solves the difficult problem of DOM programming: how to deal with incremental changes to a stateful tree structure. By abstracting away the statefulness, the Virtual DOM turns the real DOM into an immediate mode GUI, which is perfect for functional programming.
|
||||
>
|
||||
> [Read the full post...](http://www.lispcast.com/react-another-level-of-indirection)
|
||||
|
||||
## Reagent: Minimalistic React for ClojureScript
|
||||
Dan Holmsand ([@holmsand](https://twitter.com/holmsand)) created [Reagent](http://holmsand.github.io/reagent/), a simplistic ClojureScript API to React.
|
||||
|
||||
> It allows you to define efficient React components using nothing but plain ClojureScript functions and data, that describe your UI using a Hiccup-like syntax.
|
||||
>
|
||||
> The goal of Reagent is to make it possible to define arbitrarily complex UIs using just a couple of basic concepts, and to be fast enough by default that you rarely have to care about performance.
|
||||
>
|
||||
> [Check it out on Github...](http://holmsand.github.io/reagent/)
|
||||
|
||||
|
||||
## Functional DOM programming
|
||||
|
||||
React's one-way data-binding naturally lends itself to a functional programming approach. Facebook's Pete Hunt ([@floydophone](https://twitter.com/floydophone)) explores how one would go about [writing web apps in a functional manner](https://medium.com/p/67d81637d43). Spoiler alert:
|
||||
|
||||
> This is React. It’s not about templates, or data binding, or DOM manipulation. It’s about using functional programming with a virtual DOM representation to build ambitious, high-performance apps with JavaScript.
|
||||
>
|
||||
> [Read the full post...](https://medium.com/p/67d81637d43)
|
||||
|
||||
Pete also explains this in detail at his #MeteorDevShop talk (about 30 Minutes):
|
||||
|
||||
<iframe width="560" height="315" src="//www.youtube.com/embed/Lqcs6hPOcFw?start=2963" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
|
||||
|
||||
## Kioo: Separating markup and logic
|
||||
[Creighton Kirkendall](https://github.com/ckirkendall) created [Kioo](https://github.com/ckirkendall/kioo), which adds Enlive-style templating to React. HTML templates are separated from the application logic. Kioo comes with separate examples for both Om and Reagent.
|
||||
|
||||
A basic example from github:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
<header>
|
||||
<h1>Header placeholder</h1>
|
||||
<ul id="navigation">
|
||||
<li class="nav-item"><a href="#">Placeholder</a></li>
|
||||
</ul>
|
||||
</header>
|
||||
<div class="content">place holder</div>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
```clojure
|
||||
...
|
||||
|
||||
(defn my-nav-item [[caption func]]
|
||||
(kioo/component "main.html" [:.nav-item]
|
||||
{[:a] (do-> (content caption)
|
||||
(set-attr :onClick func))}))
|
||||
|
||||
(defn my-header [heading nav-elms]
|
||||
(kioo/component "main.html" [:header]
|
||||
{[:h1] (content heading)
|
||||
[:ul] (content (map my-nav-item nav-elms))}))
|
||||
|
||||
(defn my-page [data]
|
||||
(kioo/component "main.html"
|
||||
{[:header] (substitute (my-header (:heading data)
|
||||
(:navigation data)))
|
||||
[:.content] (content (:content data))}))
|
||||
|
||||
(def app-state (atom {:heading "main"
|
||||
:content "Hello World"
|
||||
:navigation [["home" #(js/alert %)]
|
||||
["next" #(js/alert %)]]}))
|
||||
|
||||
(om/root app-state my-page (.-body js/document))
|
||||
```
|
||||
|
||||
## Om
|
||||
|
||||
In an interview with David Nolen, Tom Coupland ([@tcoupland](https://twitter.com/tcoupland)) of InfoQ provides a nice summary of recent developments around Om ("[Om: Enhancing Facebook's React with Immutability](http://www.infoq.com/news/2014/01/om-react)").
|
||||
|
||||
> David [Nolen]: I think people are starting to see the limitations of just JavaScript and jQuery and even more structured solutions like Backbone, Angular, Ember, etc. React is a fresh approach to the DOM problem that seems obvious in hindsight.
|
||||
>
|
||||
> [Read the full interview...](http://www.infoq.com/news/2014/01/om-react)
|
||||
|
||||
### A slice of React, ClojureScript and Om
|
||||
|
||||
Fredrik Dyrkell ([@lexicallyscoped](https://twitter.com/lexicallyscoped)) rewrote part of the [React tutorial in both ClojureScript and Om](http://www.lexicallyscoped.com/2013/12/25/slice-of-reactjs-and-cljs.html), along with short, helpful explanations.
|
||||
|
||||
> React has sparked a lot of interest in the Clojure community lately [...]. At the very core, React lets you build up your DOM representation in a functional fashion by composing pure functions and you have a simple building block for everything: React components.
|
||||
>
|
||||
> [Read the full post...](http://www.lexicallyscoped.com/2013/12/25/slice-of-reactjs-and-cljs.html)
|
||||
|
||||
In a separate post, Dyrkell breaks down [how to build a binary clock component](http://www.lexicallyscoped.com/2014/01/23/ClojureScript-react-om-binary-clock.html) in Om.
|
||||
|
||||
[[Demo](http://www.lexicallyscoped.com/demo/binclock/)] [[Code](https://github.com/fredyr/binclock/blob/master/src/binclock/core.cljs)]
|
||||
|
||||
### Time Travel: Implementing undo in Om
|
||||
David Nolen shows how to leverage immutable data structures to [add global undo](http://swannodette.github.io/2013/12/31/time-travel/) functionality to an app – using just 13 lines of ClojureScript.
|
||||
|
||||
### A Step-by-Step Om Walkthrough
|
||||
|
||||
[Josh Lehman](http://www.joshlehman.me) took the time to create an extensive [step-by-step walkthrough](http://www.joshlehman.me/rewriting-the-react-tutorial-in-om/) of the React tutorial in Om. The well-documented source is on [github](https://github.com/jalehman/omtut-starter).
|
||||
|
||||
### Omkara
|
||||
|
||||
[brendanyounger](https://github.com/brendanyounger) created [omkara](https://github.com/brendanyounger/omkara), a starting point for ClojureScript web apps based on Om/React. It aims to take advantage of server-side rendering and comes with a few tips on getting started with Om/React projects.
|
||||
|
||||
### Om Experience Report
|
||||
Adam Solove ([@asolove](https://twitter.com/asolove/)) [dives a little deeper into Om, React and ClojureScript](http://adamsolove.com/js/clojure/2014/01/06/om-experience-report.html). He shares some helpful tips he gathered while building his [CartoCrayon](https://github.com/asolove/carto-crayon) prototype.
|
||||
|
||||
## Not-so-random Tweet
|
||||
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>[@swannodette](https://twitter.com/swannodette) No thank you! It's honestly a bit weird because Om is exactly what I didn't know I wanted for doing functional UI work.</p>— Adam Solove (@asolove) <a href="https://twitter.com/asolove/status/420294067637858304">January 6, 2014</a></blockquote></div>
|
||||
86
docs/_posts/2014-02-15-community-roundup-16.md
Normal file
86
docs/_posts/2014-02-15-community-roundup-16.md
Normal file
@@ -0,0 +1,86 @@
|
||||
---
|
||||
title: "Community Round-up #16"
|
||||
layout: post
|
||||
author: Jonas Gebhardt
|
||||
---
|
||||
|
||||
There have been many posts recently covering the <i>why</i> and <i>how</i> of React. This week's community round-up includes a collection of recent articles to help you get started with React, along with a few posts that explain some of the inner workings.
|
||||
|
||||
|
||||
## React in a nutshell
|
||||
Got five minutes to pitch React to your coworkers? John Lynch ([@johnrlynch](https://twitter.com/johnrlynch)) put together [this excellent and refreshing slideshow](http://slid.es/johnlynch/reactjs):
|
||||
|
||||
<iframe src="//slid.es/johnlynch/reactjs/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
|
||||
|
||||
|
||||
|
||||
## React's diff algorithm
|
||||
|
||||
React core team member Christopher Chedeau ([@vjeux](https://twitter.com/vjeux)) explores the innards of React's tree diffing algorithm in this [extensive and well-illustrated post](http://calendar.perfplanet.com/2013/diff/). <figure>[](http://calendar.perfplanet.com/2013/diff/)</figure>
|
||||
|
||||
While we're talking about tree diffing: Matt Esch ([@MatthewEsch](https://twitter.com/MatthewEsch)) created [this project](https://github.com/Matt-Esch/virtual-dom), which aims to implement the virtual DOM and a corresponding diff algorithm as separate modules.
|
||||
|
||||
|
||||
|
||||
|
||||
## Many, many new introductions to React!
|
||||
|
||||
|
||||
|
||||
James Padosley wrote a short post on the basics (and merits) of React: [What is React?](http://james.padolsey.com/javascript/what-is-react/)
|
||||
> What I like most about React is that it doesn't impose heady design patterns and data-modelling abstractions on me. [...] Its opinions are so minimal and its abstractions so focused on the problem of the DOM, that you can merrily slap your design choices atop.
|
||||
|
||||
> [Read the full post...](http://james.padolsey.com/javascript/what-is-react/)
|
||||
|
||||
Taylor Lapeyre ([@taylorlapeyre](https://twitter.com/taylorlapeyre)) wrote another nice [introduction to React](http://words.taylorlapeyre.me/an-introduction-to-react).
|
||||
|
||||
> React expects you to do the work of getting and pushing data from the server. This makes it very easy to implement React as a front end solution, since it simply expects you to hand it data. React does all the other work.
|
||||
|
||||
> [Read the full post...](http://words.taylorlapeyre.me/an-introduction-to-react)
|
||||
|
||||
|
||||
[This "Deep explanation for newbies"](http://www.webdesignporto.com/react-js-in-pure-javascript-facebook-library/?utm_source=echojs&utm_medium=post&utm_campaign=echojs) by [@ProJavaScript](https://twitter.com/ProJavaScript) explains how to get started building a React game without using the optional JSX syntax.
|
||||
|
||||
### React around the world
|
||||
|
||||
It's great to see the React community expand internationally. [This site](http://habrahabr.ru/post/189230/) features a React introduction in Russian.
|
||||
|
||||
### React tutorial series
|
||||
|
||||
[Christopher Pitt](https://medium.com/@followchrisp) explains [React Components](https://medium.com/react-tutorials/828c397e3dc8) and [React Properties](https://medium.com/react-tutorials/ef11cd55caa0). The former includes a nice introduction to using JSX, while the latter focuses on adding interactivity and linking multiple components together. Also check out the [other posts in his React Tutorial series](https://medium.com/react-tutorials), e.g. on using [React + Backbone Model](https://medium.com/react-tutorials/8aaec65a546c) and [React + Backbone Router](https://medium.com/react-tutorials/c00be0cf1592).
|
||||
|
||||
### Beginner tutorial: Implementing the board game Go
|
||||
|
||||
[Chris LaRose](http://cjlarose.com/) walks through the steps of creating a Go app in React, showing how to separate application logic from the rendered components. Check out his [tutorial](http://cjlarose.com/2014/01/09/react-board-game-tutorial.html) or go straight to the [code](https://github.com/cjlarose/react-go).
|
||||
|
||||
### Egghead.io video tutorials
|
||||
|
||||
Joe Maddalone ([@joemaddalone](https://twitter.com/joemaddalone)) of [egghead.io](https://egghead.io/) created a series of React video tutorials, such as [this](http://www.youtube.com/watch?v=rFvZydtmsxM&feature=youtu.be&a) introduction to React Components. [[part 1](http://www.youtube.com/watch?v=rFvZydtmsxM&feature=youtu.be&a)], [[part 2](http://www.youtube.com/watch?v=5yvFLrt7N8M)]
|
||||
|
||||
### "React: Finally, a great server/client web stack"
|
||||
|
||||
Eric Florenzano ([@ericflo](https://twitter.com/ericflo)) sheds some light on what makes React perfect for server rendering:
|
||||
|
||||
> [...] the ideal solution would fully render the markup on the server, deliver it to the client so that it can be shown to the user instantly. Then it would asynchronously load some Javascript that would attach to the rendered markup, and invisibly promote the page into a full app that can render its own markup. [...]
|
||||
|
||||
> What I've discovered is that enough of the pieces have come together, that this futuristic-sounding web environment is actually surprisingly easy to do now with React.js.
|
||||
|
||||
> [Read the full post...](http://eflorenzano.com/blog/2014/01/23/react-finally-server-client/)
|
||||
|
||||
## Building a complex React component
|
||||
[Matt Harrison](http://matt-harrison.com/) walks through the process of [creating an SVG-based Resistance Calculator](http://matt-harrison.com/building-a-complex-web-component-with-facebooks-react-library/) using React. <figure>[](http://matt-harrison.com/building-a-complex-web-component-with-facebooks-react-library/)</figure>
|
||||
|
||||
|
||||
|
||||
## Random Tweets
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>[#reactjs](https://twitter.com/search?q=%23reactjs&src=hash) has very simple API, but it's amazing how much work has been done under the hood to make it blazing fast.</p>— Anton Astashov (@anton_astashov) <a href="https://twitter.com/anton_astashov/status/417556491646693378">December 30, 2013</a></blockquote></div>
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>[#reactjs]((https://twitter.com/search?q=%23reactjs&src=hash) makes refactoring your HTML as easy & natural as refactoring your javascript [@react_js](https://twitter.com/react_js)</p>— Jared Forsyth (@jaredforsyth) <a href="https://twitter.com/jaredforsyth/status/420304083010854912">January 6, 2014</a></blockquote></div>
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>Played with react.js for an hour, so many things suddenly became stupidly simple.</p>— andrewingram (@andrewingram) <a href="https://twitter.com/andrewingram/status/422810480701620225">January 13, 2014</a></blockquote></div>
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>[@okonetchnikov](https://twitter.com/okonetchnikov) HOLY CRAP react is nice</p>— julik (@julikt) <a href="https://twitter.com/julikt/status/422843478792765440">January 13, 2014</a></blockquote></div>
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>brb rewriting everything with react
|
||||
</p>— Ben Smithett (@bensmithett) <a href="https://twitter.com/bensmithett/status/430671242186592256">February 4, 2014</a></blockquote></div>
|
||||
133
docs/_posts/2014-02-16-react-v0.9-rc1.md
Normal file
133
docs/_posts/2014-02-16-react-v0.9-rc1.md
Normal file
@@ -0,0 +1,133 @@
|
||||
---
|
||||
title: React v0.9 RC
|
||||
layout: post
|
||||
author: Ben Alpert
|
||||
---
|
||||
|
||||
We're almost ready to release React v0.9! We're posting a release candidate so that you can test your apps on it; we'd much prefer to find show-stopping bugs now rather than after we release.
|
||||
|
||||
The release candidate is available for download from the CDN:
|
||||
|
||||
* **React**
|
||||
Dev build with warnings: <http://fb.me/react-0.9.0-rc1.js>
|
||||
Minified build for production: <http://fb.me/react-0.9.0-rc1.min.js>
|
||||
* **React with Add-Ons**
|
||||
Dev build with warnings: <http://fb.me/react-with-addons-0.9.0-rc1.js>
|
||||
Minified build for production: <http://fb.me/react-with-addons-0.9.0-rc1.min.js>
|
||||
* **In-Browser JSX transformer**
|
||||
<http://fb.me/JSXTransformer-0.9.0-rc1.js>
|
||||
|
||||
We've also published version `0.9.0-rc1` of the `react` and `react-tools` packages on npm and the `react` package on bower.
|
||||
|
||||
Please try these builds out and [file an issue on GitHub](https://github.com/facebook/react/issues/new) if you see anything awry.
|
||||
|
||||
## Upgrade Notes
|
||||
|
||||
In addition to the changes to React core listed below, we've made a small change to the way JSX interprets whitespace to make things more consistent. With this release, space between two components on the same line will be preserved, while a newline separating a text node from a tag will be eliminated in the output. Consider the code:
|
||||
|
||||
```html
|
||||
<div>
|
||||
Monkeys:
|
||||
{listOfMonkeys} {submitButton}
|
||||
</div>
|
||||
```
|
||||
|
||||
In v0.8 and below, it was transformed to the following:
|
||||
|
||||
```javascript
|
||||
React.DOM.div(null,
|
||||
" Monkeys: ",
|
||||
listOfMonkeys, submitButton
|
||||
)
|
||||
```
|
||||
|
||||
In v0.9, it will be transformed to this JS instead:
|
||||
|
||||
```javascript{2,3}
|
||||
React.DOM.div(null,
|
||||
"Monkeys:",
|
||||
listOfMonkeys, " ", submitButton
|
||||
)
|
||||
```
|
||||
|
||||
We believe this new behavior is more helpful and elimates cases where unwanted whitespace was previously added.
|
||||
|
||||
In cases where you want to preserve the space adjacent to a newline, you can write a JS string like `{"Monkeys: "}` in your JSX source. We've included a script to do an automated codemod of your JSX source tree that preserves the old whitespace behavior by adding and removing spaces appropriately. You can [install jsx\_whitespace\_transformer from npm](https://github.com/facebook/react/blob/master/npm-jsx_whitespace_transformer/README.md) and run it over your source tree to modify files in place. The transformed JSX files will preserve your code's existing whitespace behavior.
|
||||
|
||||
## Changelog
|
||||
|
||||
### React Core
|
||||
|
||||
#### Breaking Changes
|
||||
|
||||
- The lifecycle methods `componentDidMount` and `componentDidUpdate` no longer receive the root node as a parameter; use `this.getDOMNode()` instead
|
||||
- Whenever a prop is equal to `undefined`, the default value returned by `getDefaultProps` will now be used instead
|
||||
- `React.unmountAndReleaseReactRootNode` was previously deprecated and has now been removed
|
||||
- `React.renderComponentToString` is now synchronous and returns the generated HTML string
|
||||
- Full-page rendering (that is, rendering the `<html>` tag using React) is now supported only when starting with server-rendered markup
|
||||
- On mouse wheel events, `deltaY` is no longer negated
|
||||
- When prop types validation fails, a warning is logged instead of an error thrown (with the production build of React, the type checks are now skipped for performance)
|
||||
- On `input`, `select`, and `textarea` elements, `.getValue()` is no longer supported; use `.getDOMNode().value` instead
|
||||
- `this.context` on components is now reserved for internal use by React
|
||||
|
||||
#### New Features
|
||||
|
||||
- React now never rethrows errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly
|
||||
- Added a new tool for profiling React components and identifying places where defining `shouldComponentUpdate` can give performance improvements
|
||||
- Added support for SVG tags `defs`, `linearGradient`, `polygon`, `radialGradient`, `stop`
|
||||
- Added support for more attributes:
|
||||
- `noValidate` and `formNoValidate` for forms
|
||||
- `property` for Open Graph `<meta>` tags
|
||||
- `sandbox`, `seamless`, and `srcDoc` for `<iframe>` tags
|
||||
- `scope` for screen readers
|
||||
- `span` for `<colgroup>` tags
|
||||
- Added support for defining `propTypes` in mixins
|
||||
- Added `any`, `arrayOf`, `component`, `oneOfType`, `renderable`, `shape` to `React.PropTypes`
|
||||
- Added support for `statics` on component spec for static component methods
|
||||
- On all events, `.currentTarget` is now properly set
|
||||
- On keyboard events, `.key` is now polyfilled in all browsers for special (non-printable) keys
|
||||
- On clipboard events, `.clipboardData` is now polyfilled in IE
|
||||
- On drag events, `.dataTransfer` is now present
|
||||
- Added support for `onMouseOver` and `onMouseOut` in addition to the existing `onMouseEnter` and `onMouseLeave` events
|
||||
- Added support for `onLoad` and `onError` on `<img>` elements
|
||||
- Added support for `onReset` on `<form>` elements
|
||||
- The `autoFocus` attribute is now polyfilled consistently on `input`, `select`, and `textarea`
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
- React no longer adds an `__owner__` property to each component's `props` object; passed-in props are now never mutated
|
||||
- When nesting top-level components (e.g., calling `React.renderComponent` within `componentDidMount`), events now properly bubble to the parent component
|
||||
- Fixed a case where nesting top-level components would throw an error when updating
|
||||
- Passing an invalid or misspelled propTypes type now throws an error
|
||||
- On mouse enter/leave events, `.target`, `.relatedTarget`, and `.type` are now set properly
|
||||
- On composition events, `.data` is now properly normalized in IE9 and IE10
|
||||
- CSS property values no longer have `px` appended for the unitless properties `columnCount`, `flex`, `flexGrow`, `flexShrink`, `lineClamp`, `order`, `widows`
|
||||
- Fixed a memory leak when unmounting children with a `componentWillUnmount` handler
|
||||
- Fixed a memory leak when `renderComponentToString` would store event handlers
|
||||
- Fixed an error that could be thrown when removing form elements during a click handler
|
||||
- `key` values containing `.` are now supported
|
||||
- Shortened `data-reactid` values for performance
|
||||
- Components now always remount when the `key` property changes
|
||||
- Event handlers are attached to `document` only when necessary, improving performance in some cases
|
||||
- Events no longer use `.returnValue` in modern browsers, eliminating a warning in Chrome
|
||||
- `scrollLeft` and `scrollTop` are no longer accessed on document.body, eliminating a warning in Chrome
|
||||
- General performance fixes, memory optimizations, improvements to warnings and error messages
|
||||
|
||||
### React with Addons
|
||||
|
||||
- `React.addons.TransitionGroup` was renamed to `React.addons.CSSTransitionGroup`
|
||||
- `React.addons.TransitionGroup` was added as a more general animation wrapper
|
||||
- `React.addons.cloneWithProps` was added for cloning components and modifying their props
|
||||
- Bug fix for adding back nodes during an exit transition for CSSTransitionGroup
|
||||
- Bug fix for changing `transitionLeave` in CSSTransitionGroup
|
||||
- Performance optimizations for CSSTransitionGroup
|
||||
- On checkbox `<input>` elements, `checkedLink` is now supported for two-way binding
|
||||
|
||||
### JSX Compiler and react-tools Package
|
||||
|
||||
- Whitespace normalization has changed; now space between two tags on the same line will be preserved, while newlines between two tags will be removed
|
||||
- The `react-tools` npm package no longer includes the React core libraries; use the `react` package instead.
|
||||
- `displayName` is now added in more cases, improving error messages and names in the React Dev Tools
|
||||
- Fixed an issue where an invalid token error was thrown after a JSX closing tag
|
||||
- `JSXTransformer` now uses source maps automatically in modern browsers
|
||||
- `JSXTransformer` error messages now include the filename and problematic line contents when a file fails to parse
|
||||
145
docs/_posts/2014-02-20-react-v0.9.md
Normal file
145
docs/_posts/2014-02-20-react-v0.9.md
Normal file
@@ -0,0 +1,145 @@
|
||||
---
|
||||
title: React v0.9
|
||||
layout: post
|
||||
author: Ben Alpert
|
||||
---
|
||||
|
||||
I'm excited to announce that today we're releasing React v0.9, which incorporates many bug fixes and several new features since the last release. This release contains almost four months of work, including over 800 commits from over 70 committers!
|
||||
|
||||
Thanks to everyone who tested the release candidate; we were able to find and fix an error in the event handling code, we upgraded envify to make running browserify on React faster, and we added support for five new attributes.
|
||||
|
||||
As always, the release is available for download from the CDN:
|
||||
|
||||
* **React**
|
||||
Dev build with warnings: <http://fb.me/react-0.9.0.js>
|
||||
Minified build for production: <http://fb.me/react-0.9.0.min.js>
|
||||
* **React with Add-Ons**
|
||||
Dev build with warnings: <http://fb.me/react-with-addons-0.9.0.js>
|
||||
Minified build for production: <http://fb.me/react-with-addons-0.9.0.min.js>
|
||||
* **In-Browser JSX Transformer**
|
||||
<http://fb.me/JSXTransformer-0.9.0.js>
|
||||
|
||||
We've also published version `0.9.0` of the `react` and `react-tools` packages on npm and the `react` package on bower.
|
||||
|
||||
## What’s New?
|
||||
|
||||
This version includes better support for normalizing event properties across all supported browsers so that you need to worry even less about cross-browser differences. We've also made many improvements to error messages and have refactored the core to never rethrow errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly.
|
||||
|
||||
We've also added to the add-ons build [React.addons.TestUtils](/react/docs/test-utils.html), a set of new utilities to help you write unit tests for React components. You can now simulate events on your components, and several helpers are provided to help make assertions about the rendered DOM tree.
|
||||
|
||||
We've also made several other improvements and a few breaking changes; the full changelog is provided below.
|
||||
|
||||
## JSX Whitespace
|
||||
|
||||
In addition to the changes to React core listed below, we've made a small change to the way JSX interprets whitespace to make things more consistent. With this release, space between two components on the same line will be preserved, while a newline separating a text node from a tag will be eliminated in the output. Consider the code:
|
||||
|
||||
```html
|
||||
<div>
|
||||
Monkeys:
|
||||
{listOfMonkeys} {submitButton}
|
||||
</div>
|
||||
```
|
||||
|
||||
In v0.8 and below, it was transformed to the following:
|
||||
|
||||
```javascript
|
||||
React.DOM.div(null,
|
||||
" Monkeys: ",
|
||||
listOfMonkeys, submitButton
|
||||
)
|
||||
```
|
||||
|
||||
In v0.9, it will be transformed to this JS instead:
|
||||
|
||||
```javascript{2,3}
|
||||
React.DOM.div(null,
|
||||
"Monkeys:",
|
||||
listOfMonkeys, " ", submitButton
|
||||
)
|
||||
```
|
||||
|
||||
We believe this new behavior is more helpful and elimates cases where unwanted whitespace was previously added.
|
||||
|
||||
In cases where you want to preserve the space adjacent to a newline, you can write `{'Monkeys: '}` or `Monkeys:{' '}` in your JSX source. We've included a script to do an automated codemod of your JSX source tree that preserves the old whitespace behavior by adding and removing spaces appropriately. You can [install jsx\_whitespace\_transformer from npm](https://github.com/facebook/react/blob/master/npm-jsx_whitespace_transformer/README.md) and run it over your source tree to modify files in place. The transformed JSX files will preserve your code's existing whitespace behavior.
|
||||
|
||||
## Changelog
|
||||
|
||||
### React Core
|
||||
|
||||
#### Breaking Changes
|
||||
|
||||
- The lifecycle methods `componentDidMount` and `componentDidUpdate` no longer receive the root node as a parameter; use `this.getDOMNode()` instead
|
||||
- Whenever a prop is equal to `undefined`, the default value returned by `getDefaultProps` will now be used instead
|
||||
- `React.unmountAndReleaseReactRootNode` was previously deprecated and has now been removed
|
||||
- `React.renderComponentToString` is now synchronous and returns the generated HTML string
|
||||
- Full-page rendering (that is, rendering the `<html>` tag using React) is now supported only when starting with server-rendered markup
|
||||
- On mouse wheel events, `deltaY` is no longer negated
|
||||
- When prop types validation fails, a warning is logged instead of an error thrown (with the production build of React, type checks are now skipped for performance)
|
||||
- On `input`, `select`, and `textarea` elements, `.getValue()` is no longer supported; use `.getDOMNode().value` instead
|
||||
- `this.context` on components is now reserved for internal use by React
|
||||
|
||||
#### New Features
|
||||
|
||||
- React now never rethrows errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly
|
||||
- Added support for SVG tags `defs`, `linearGradient`, `polygon`, `radialGradient`, `stop`
|
||||
- Added support for more attributes:
|
||||
- `crossOrigin` for CORS requests
|
||||
- `download` and `hrefLang` for `<a>` tags
|
||||
- `mediaGroup` and `muted` for `<audio>` and `<video>` tags
|
||||
- `noValidate` and `formNoValidate` for forms
|
||||
- `property` for Open Graph `<meta>` tags
|
||||
- `sandbox`, `seamless`, and `srcDoc` for `<iframe>` tags
|
||||
- `scope` for screen readers
|
||||
- `span` for `<colgroup>` tags
|
||||
- Added support for defining `propTypes` in mixins
|
||||
- Added `any`, `arrayOf`, `component`, `oneOfType`, `renderable`, `shape` to `React.PropTypes`
|
||||
- Added support for `statics` on component spec for static component methods
|
||||
- On all events, `.currentTarget` is now properly set
|
||||
- On keyboard events, `.key` is now polyfilled in all browsers for special (non-printable) keys
|
||||
- On clipboard events, `.clipboardData` is now polyfilled in IE
|
||||
- On drag events, `.dataTransfer` is now present
|
||||
- Added support for `onMouseOver` and `onMouseOut` in addition to the existing `onMouseEnter` and `onMouseLeave` events
|
||||
- Added support for `onLoad` and `onError` on `<img>` elements
|
||||
- Added support for `onReset` on `<form>` elements
|
||||
- The `autoFocus` attribute is now polyfilled consistently on `input`, `select`, and `textarea`
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
- React no longer adds an `__owner__` property to each component's `props` object; passed-in props are now never mutated
|
||||
- When nesting top-level components (e.g., calling `React.renderComponent` within `componentDidMount`), events now properly bubble to the parent component
|
||||
- Fixed a case where nesting top-level components would throw an error when updating
|
||||
- Passing an invalid or misspelled propTypes type now throws an error
|
||||
- On mouse enter/leave events, `.target`, `.relatedTarget`, and `.type` are now set properly
|
||||
- On composition events, `.data` is now properly normalized in IE9 and IE10
|
||||
- CSS property values no longer have `px` appended for the unitless properties `columnCount`, `flex`, `flexGrow`, `flexShrink`, `lineClamp`, `order`, `widows`
|
||||
- Fixed a memory leak when unmounting children with a `componentWillUnmount` handler
|
||||
- Fixed a memory leak when `renderComponentToString` would store event handlers
|
||||
- Fixed an error that could be thrown when removing form elements during a click handler
|
||||
- Boolean attributes such as `disabled` are rendered without a value (previously `disabled="true"`, now simply `disabled`)
|
||||
- `key` values containing `.` are now supported
|
||||
- Shortened `data-reactid` values for performance
|
||||
- Components now always remount when the `key` property changes
|
||||
- Event handlers are attached to `document` only when necessary, improving performance in some cases
|
||||
- Events no longer use `.returnValue` in modern browsers, eliminating a warning in Chrome
|
||||
- `scrollLeft` and `scrollTop` are no longer accessed on document.body, eliminating a warning in Chrome
|
||||
- General performance fixes, memory optimizations, improvements to warnings and error messages
|
||||
|
||||
### React with Addons
|
||||
|
||||
- `React.addons.TestUtils` was added to help write unit tests
|
||||
- `React.addons.TransitionGroup` was renamed to `React.addons.CSSTransitionGroup`
|
||||
- `React.addons.TransitionGroup` was added as a more general animation wrapper
|
||||
- `React.addons.cloneWithProps` was added for cloning components and modifying their props
|
||||
- Bug fix for adding back nodes during an exit transition for CSSTransitionGroup
|
||||
- Bug fix for changing `transitionLeave` in CSSTransitionGroup
|
||||
- Performance optimizations for CSSTransitionGroup
|
||||
- On checkbox `<input>` elements, `checkedLink` is now supported for two-way binding
|
||||
|
||||
### JSX Compiler and react-tools Package
|
||||
|
||||
- Whitespace normalization has changed; now space between two tags on the same line will be preserved, while newlines between two tags will be removed
|
||||
- The `react-tools` npm package no longer includes the React core libraries; use the `react` package instead.
|
||||
- `displayName` is now added in more cases, improving error messages and names in the React Dev Tools
|
||||
- Fixed an issue where an invalid token error was thrown after a JSX closing tag
|
||||
- `JSXTransformer` now uses source maps automatically in modern browsers
|
||||
- `JSXTransformer` error messages now include the filename and problematic line contents when a file fails to parse
|
||||
95
docs/_posts/2014-02-24-community-roundup-17.md
Normal file
95
docs/_posts/2014-02-24-community-roundup-17.md
Normal file
@@ -0,0 +1,95 @@
|
||||
---
|
||||
title: "Community Round-up #17"
|
||||
layout: post
|
||||
author: Jonas Gebhardt
|
||||
---
|
||||
|
||||
|
||||
It's exciting to see the number of real-world React applications and components skyrocket over the past months! This community round-up features a few examples of inspiring React applications and components.
|
||||
|
||||
## React in the Real World
|
||||
|
||||
### Facebook Lookback video editor
|
||||
Large parts of Facebook's web frontend are already powered by React. The recently released Facebook [Lookback video and its corresponding editor](https://www.facebook.com/lookback/edit/) are great examples of a complex, real-world React app.
|
||||
|
||||
### Russia's largest bank is now powered by React
|
||||
Sberbank, Russia's largest bank, recently switched large parts of their site to use React, as detailed in [this post by Vyacheslav Slinko](https://groups.google.com/forum/#!topic/reactjs/Kj6WATX0atg).
|
||||
|
||||
### Relato
|
||||
[Relato](http://bripkens.github.io/relato/) by [Ben Ripkens](https://github.com/bripkens) shows Open Source Statistics based on npm data. It features a filterable and sortable table built in React. Check it out – it's super fast!
|
||||
|
||||
### Makona Editor
|
||||
|
||||
John Lynch ([@johnrlynch](https://twitter.com/johnrlynch)) created Makona, a block-style document editor for the web. Blocks of different content types comprise documents, authored using plain markup. At the switch of a toggle, block contents are then rendered on the page. While not quite a WYSIWYG editor, Makona uses plain textareas for input. This makes it compatible with a wider range of platforms than traditional rich text editors.
|
||||
<figure>[](http://johnthethird.github.io/makona-editor/)</figure>
|
||||
|
||||
### Create Chrome extensions using React
|
||||
React is in no way limited to just web pages. Brandon Tilley ([@BinaryMuse](https://twitter.com/BinaryMuse)) just released a detailed walk-through of [how he built his Chrome extension "Fast Tab Switcher" using React](http://brandontilley.com/2014/02/24/creating-chrome-extensions-with-react.html).
|
||||
|
||||
|
||||
### Twitter Streaming Client
|
||||
|
||||
Javier Aguirre ([@javaguirre](https://twitter.com/javaguirre)) put together a simple [twitter streaming client using node, socket.io and React](http://javaguirre.net/2014/02/11/twitter-streaming-api-with-node-socket-io-and-reactjs/).
|
||||
|
||||
|
||||
### Sproutsheet
|
||||
|
||||
[Sproutsheet](http://sproutsheet.com/) is a gardening calendar. You can use it to track certain events that happen in the life of your plants. It's currently in beta and supports localStorage, and data/image import and export.
|
||||
|
||||
### Instant Domain Search
|
||||
[Instant Domain Search](https://instantdomainsearch.com/) also uses React. It sure is instant!
|
||||
|
||||
|
||||
### SVG-based graphical node editor
|
||||
[NoFlo](http://noflojs.org/) and [Meemoo](http://meemoo.org/) developer [Forresto Oliphant](http://www.forresto.com/) built an awesome SVG-based [node editor](http://forresto.github.io/prototyping/react/) in React.
|
||||
<figure>[](http://forresto.github.io/prototyping/react/)</figure>
|
||||
|
||||
|
||||
### Ultimate Tic-Tac-Toe Game in React
|
||||
Rafał Cieślak ([@Ravicious](https://twitter.com/Ravicious)) wrote a [React version](http://ravicious.github.io/ultimate-ttt/) of [Ultimate Tic Tac Toe](http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/). Find the source [here](https://github.com/ravicious/ultimate-ttt).
|
||||
|
||||
|
||||
|
||||
### ReactJS Gallery
|
||||
|
||||
[Emanuele Rampichini](https://github.com/lele85)'s [ReactJS Gallery](https://github.com/lele85/ReactGallery) is a cool demo app that shows fullscreen images from a folder on the server. If the folder content changes, the gallery app updates via websockets.
|
||||
|
||||
Emanuele shared this awesome demo video with us:
|
||||
|
||||
<iframe width="560" height="315" src="//www.youtube.com/embed/jYcpaemt90M" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
|
||||
|
||||
## React Components
|
||||
|
||||
|
||||
### Table Sorter
|
||||
[Table Sorter](http://bgerm.github.io/react-table-sorter-demo/) by [bgerm](https://github.com/bgerm) [[source](https://github.com/bgerm/react-table-sorter-demo)] is another helpful React component.
|
||||
|
||||
### Static-search
|
||||
|
||||
Dmitry Chestnykh [@dchest](https://twitter.com/dchest) wrote a [static search indexer](https://github.com/dchest/static-search) in Go, along with a [React-based web front-end](http://www.codingrobots.com/search/) that consumes search result via JSON.
|
||||
|
||||
### Lorem Ipsum component
|
||||
|
||||
[Martin Andert](https://github.com/martinandert) created [react-lorem-component](https://github.com/martinandert/react-lorem-component), a simple component for all your placeholding needs.
|
||||
|
||||
### Input with placeholder shim
|
||||
[react-input=placeholder](https://github.com/enigma-io/react-input-placeholder) by [enigma-io](https://github.com/enigma-io) is a small wrapper around React.DOM.input that shims in placeholder functionality for browsers that don't natively support it.
|
||||
|
||||
### diContainer
|
||||
|
||||
[dicontainer](https://github.com/SpektrumFM/dicontainer) provides a dependency container that lets you inject Angular-style providers and services as simple React.js Mixins.
|
||||
|
||||
|
||||
## React server rendering
|
||||
|
||||
Ever wonder how to pre-render React components on the server? [react-server-example](https://github.com/mhart/react-server-example) by Michael Hart ([@hichaelmart](http://twitter.com/hichaelmart)) walks through the necessary steps.
|
||||
|
||||
Similarly, Alan deLevie ([@adelevie](https://twitter.com/adelevie)) created [react-client-server-starter](https://github.com/adelevie/react-client-server-starter), another detailed walk-through of how to server-render your app.
|
||||
|
||||
|
||||
|
||||
## Random Tweet
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>Recent changes: web ui is being upgraded to [#reactjs](https://twitter.com/search?q=%23reactjs&src=hash), HEAD~4 at [https://camlistore.googlesource.com/camlistore/](https://camlistore.googlesource.com/camlistore/)</p>— Camlistore (@Camlistore) <a href="https://twitter.com/Camlistore/status/423925795820539904">January 16, 2014</a></blockquote></div>
|
||||
106
docs/_posts/2014-03-14-community-roundup-18.md
Normal file
106
docs/_posts/2014-03-14-community-roundup-18.md
Normal file
@@ -0,0 +1,106 @@
|
||||
---
|
||||
title: "Community Round-up #18"
|
||||
layout: post
|
||||
author: Jonas Gebhardt
|
||||
---
|
||||
|
||||
In this Round-up, we are taking a few closer looks at React's interplay with different frameworks and architectures.
|
||||
|
||||
## "Little framework BIG splash"
|
||||
|
||||
Let's start with yet another refreshing introduction to React: Craig Savolainen ([@maedhr](https://twitter.com/maedhr)) walks through some first steps, demonstrating [how to build a Google Maps component](http://infinitemonkeys.influitive.com/little-framework-big-splash) using React.
|
||||
|
||||
## Architecting your app with react
|
||||
|
||||
Brandon Konkle ([@bkonkle](https://twitter.com/bkonkle))
|
||||
[Architecting your app with react](http://lincolnloop.com/blog/architecting-your-app-react-part-1/)
|
||||
We're looking forward to part 2!
|
||||
|
||||
> React is not a full MVC framework, and this is actually one of its strengths. Many who adopt React choose to do so alongside their favorite MVC framework, like Backbone. React has no opinions about routing or syncing data, so you can easily use your favorite tools to handle those aspects of your frontend application. You'll often see React used to manage specific parts of an application's UI and not others. React really shines, however, when you fully embrace its strategies and make it the core of your application's interface.
|
||||
>
|
||||
> [Read the full article...](http://lincolnloop.com/blog/architecting-your-app-react-part-1/)
|
||||
|
||||
## React vs. async DOM manipulation
|
||||
|
||||
Eliseu Monar ([@eliseumds](https://twitter.com/eliseumds))'s post "[ReactJS vs async concurrent rendering](http://eliseu.tk/post/77843550010/vitalbox-pchr-reactjs-vs-async-concurrent-rendering)" is a great example of how React quite literally renders a whole array of common web development work(arounds) obsolete.
|
||||
|
||||
|
||||
|
||||
## React, Scala and the Play Framework
|
||||
[Matthias Nehlsen](http://matthiasnehlsen.com/) wrote a detailed introductory piece on [React and the Play Framework](http://matthiasnehlsen.com/blog/2014/01/05/play-framework-and-facebooks-react-library/), including a helpful architectural diagram of a typical React app.
|
||||
|
||||
Nehlsen's React frontend is the second implementation of his chat application's frontend, following an AngularJS version. Both implementations are functionally equivalent and offer some perspective on differences between the two frameworks.
|
||||
|
||||
In [another article](http://matthiasnehlsen.com/blog/2014/01/24/scala-dot-js-and-reactjs/), he walks us through the process of using React with scala.js to implement app-wide undo functionality.
|
||||
|
||||
Also check out his [talk](http://m.ustream.tv/recorded/42780242) at Ping Conference 2014, in which he walks through a lot of the previously content in great detail.
|
||||
|
||||
## React and Backbone
|
||||
|
||||
The folks over at [Venmo](https://venmo.com/) are using React in conjunction with Backbone.
|
||||
Thomas Boyt ([@thomasaboyt](https://twitter.com/thomasaboyt)) wrote [this detailed piece](http://www.thomasboyt.com/2013/12/17/using-reactjs-as-a-backbone-view.html) about why React and Backbone are "a fantastic pairing".
|
||||
|
||||
## React vs. Ember
|
||||
|
||||
Eric Berry ([@coderberry](https://twitter.com/coderberry)) developed Ember equivalents for some of the official React examples. Read his post for a side-by-side comparison of the respective implementations: ["Facebook React vs. Ember"](http://instructure.github.io/blog/2013/12/17/facebook-react-vs-ember/).
|
||||
|
||||
|
||||
## React and plain old HTML
|
||||
|
||||
Daniel Lo Nigro ([@Daniel15](https://twitter.com/Daniel15)) created [React-Magic](https://github.com/reactjs/react-magic), which leverages React to ajaxify plain old html pages and even [allows CSS transitions between pageloads](http://stuff.dan.cx/facebook/react-hacks/magic/red.php).
|
||||
|
||||
> React-Magic intercepts all navigation (link clicks and form posts) and loads the requested page via an AJAX request. React is then used to "diff" the old HTML with the new HTML, and only update the parts of the DOM that have been changed.
|
||||
>
|
||||
> [Check out the project on GitHub...](https://github.com/reactjs/react-magic)
|
||||
|
||||
On a related note, [Reactize](https://turbo-react.herokuapp.com/) by Ross Allen ([@ssorallen](https://twitter.com/ssorallen)) is a similarly awesome project: A wrapper for Rails' [Turbolinks](https://github.com/rails/turbolinks/), which seems to have inspired John Lynch ([@johnrlynch](https://twitter.com/johnrlynch)) to then create [a server-rendered version using the JSX transformer in Rails middleware](http://www.rigelgroupllc.com/blog/2014/01/12/react-jsx-transformer-in-rails-middleware/).
|
||||
|
||||
## React and Object.observe
|
||||
Check out [François de Campredon](https://github.com/fdecampredon)'s implementation of [TodoMVC based on React and ES6's Object.observe](https://github.com/fdecampredon/react-observe-todomvc/).
|
||||
|
||||
|
||||
## React and Angular
|
||||
|
||||
Ian Bicking ([@ianbicking](https://twitter.com/ianbicking)) of Mozilla Labs [explains why he "decided to go with React instead of Angular.js"](https://plus.google.com/+IanBicking/posts/Qj8R5SWAsfE).
|
||||
|
||||
### ng-React Update
|
||||
|
||||
[David Chang](https://github.com/davidchang) works through some performance improvements of his [ngReact](https://github.com/davidchang/ngReact) project. His post ["ng-React Update - React 0.9 and Angular Track By"](http://davidandsuzi.com/ngreact-update/) includes some helpful advice on boosting render performance for Angular components.
|
||||
|
||||
> Angular gives you a ton of functionality out of the box - a full MV* framework - and I am a big fan, but I'll admit that you need to know how to twist the right knobs to get performance.
|
||||
>
|
||||
> That said, React gives you a very strong view component out of the box with the performance baked right in. Try as I did, I couldn't actually get it any faster. So pretty impressive stuff.
|
||||
>
|
||||
>[Read the full post...](http://davidandsuzi.com/ngreact-update/)
|
||||
|
||||
|
||||
React was also recently mentioned at ng-conf, where the Angular team commented on React's concept of the virtual DOM:
|
||||
|
||||
<iframe width="560" height="315" src="//www.youtube.com/embed/srt3OBP2kGc?start=113" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
## React and Web Components
|
||||
|
||||
Jonathan Krause ([@jonykrause](https://twitter.com/jonykrause)) offers his thoughts regarding [parallels between React and Web Components](http://jonykrau.se/posts/the-value-of-react), highlighting the value of React's ability to render pages on the server practically for free.
|
||||
|
||||
## Immutable React
|
||||
|
||||
[Peter Hausel](http://pk11.kinja.com/) shows how to build a Wikipedia auto-complete demo based on immutable data structures (similar to [mori](https://npmjs.org/package/mori)), really taking advantage of the framework's one-way reactive data binding:
|
||||
|
||||
> Its truly reactive design makes DOM updates finally sane and when combined with persistent data structures one can experience JavaScript development like it was never done before.
|
||||
|
||||
> [Read the full post](http://tech.kinja.com/immutable-react-1495205675)
|
||||
|
||||
|
||||
## D3 and React
|
||||
|
||||
[Ben Smith](http://10consulting.com/) built some great SVG-based charting components using a little less of D3 and a little more of React: [D3 and React - the future of charting components?](http://10consulting.com/2014/02/19/d3-plus-reactjs-for-charting/)
|
||||
|
||||
## Om and React
|
||||
Josh Haberman ([@joshhaberman](https://twitter.com/JoshHaberman)) discusses performance differences between React, Om and traditional MVC frameworks in "[A closer look at OM vs React performance](http://blog.reverberate.org/2014/02/on-future-of-javascript-mvc-frameworks.html)".
|
||||
|
||||
Speaking of Om: [Omchaya](https://github.com/sgrove/omchaya) by Sean Grove ([@sgrove](https://twitter.com/sgrove)) is a neat Cljs/Om example project.
|
||||
|
||||
|
||||
## Random Tweets
|
||||
|
||||
<div><blockquote class="twitter-tweet" lang="en"><p>Worked for 2 hours on a [@react_js](https://twitter.com/react_js) app sans internet. Love that I could get stuff done with it without googling every question.</p>— John Shimek (@varikin) <a href="https://twitter.com/varikin/status/436606891657949185">February 20, 2014</a></blockquote></div>
|
||||
71
docs/_posts/2014-03-19-react-v0.10-rc1.md
Normal file
71
docs/_posts/2014-03-19-react-v0.10-rc1.md
Normal file
@@ -0,0 +1,71 @@
|
||||
---
|
||||
title: React v0.10 RC
|
||||
layout: post
|
||||
author: Paul O’Shannessy
|
||||
---
|
||||
|
||||
[v0.9 has only been out for a month](http://facebook.github.io/react/blog/2014/02/20/react-v0.9.html), but we’re getting ready to push out v0.10 already. Unlike v0.9 which took a long time, we don't have a long list of changes to talk about.
|
||||
|
||||
The release candidate is available for download from the CDN:
|
||||
|
||||
* **React**
|
||||
Dev build with warnings: <http://fb.me/react-0.10.0-rc1.js>
|
||||
Minified build for production: <http://fb.me/react-0.10.0-rc1.min.js>
|
||||
* **React with Add-Ons**
|
||||
Dev build with warnings: <http://fb.me/react-with-addons-0.10.0-rc1.js>
|
||||
Minified build for production: <http://fb.me/react-with-addons-0.10.0-rc1.min.js>
|
||||
* **In-Browser JSX transformer**
|
||||
<http://fb.me/JSXTransformer-0.10.0-rc1.js>
|
||||
|
||||
We've also published version `0.10.0-rc1` of the `react` and `react-tools` packages on npm and the `react` package on bower.
|
||||
|
||||
Please try these builds out and [file an issue on GitHub](https://github.com/facebook/react/issues/new) if you see anything awry.
|
||||
|
||||
## Clone On Mount
|
||||
|
||||
The main purpose of this release is to provide a smooth upgrade path as we evolve some of the implementation of core. In v0.9 we started warning in cases where you called methods on unmounted components. This is part of an effort to enforce the idea that the return value of a component (`React.DOM.div()`, `MyComponent()`) is in fact not a reference to the component instance React uses in the virtual DOM. The return value is instead a light-weight object that React knows how to use. Since the return value currently is a reference to the same object React uses internally, we need to make this transition in stages as many people have come to depend on this implementation detail.
|
||||
|
||||
In 0.10, we’re adding more warnings to catch a similar set of patterns. When a component is mounted we clone it and use that object for our internal representation. This allows us to capture calls you think you’re making to a mounted component. We’ll forward them on to the right object, but also warn you that this is breaking. See “Access to the Mounted Instance” on [this page](http://fb.me/react-warning-descriptors). Most of the time you can solve your pattern by using refs.
|
||||
|
||||
Storing a reference to your top level component is a pattern touched upon on that page, but another examples that demonstrates what we see a lot of:
|
||||
|
||||
```js
|
||||
// This is a common pattern. However instance here really refers to a
|
||||
// "descriptor", not necessarily the mounted instance.
|
||||
var instance = <MyComponent/>;
|
||||
React.renderComponent(instance);
|
||||
// ...
|
||||
instance.setProps(...);
|
||||
|
||||
// The change here is very simple. The return value of renderComponent will be
|
||||
// the mounted instance.
|
||||
var instance = React.renderComponent(<MyComponent/>)
|
||||
// ...
|
||||
instance.setProps(...);
|
||||
```
|
||||
|
||||
These warnings and method forwarding are only enabled in the development build. The production builds continue to work as they did in v0.9. We strongly encourage you to use the development builds to catch these warnings and fix the call sites.
|
||||
|
||||
The plan for v0.11 is that we will go fully to "descriptors". Method calls on the return value of `MyComponent()` will fail hard.
|
||||
|
||||
## Changelog
|
||||
|
||||
### React Core
|
||||
|
||||
#### New Features
|
||||
* Made it possible to server render without React-related markup (`data-reactid`, `data-react-checksum`) - `React.renderComponentToStaticMarkup`
|
||||
* Added support for more attributes:
|
||||
* `srcSet` for `<img>` to images at different pixel ratios
|
||||
* `textAnchor` for SVG
|
||||
|
||||
#### Bug Fixes
|
||||
* Ensure all void elements don’t insert a closing tag into the markup.
|
||||
* Ensure `className={false}` behaves consistently
|
||||
* Ensure `this.refs` is defined, even if no refs are specified.
|
||||
|
||||
### Addons
|
||||
|
||||
* `update` function to deal with immutable data.
|
||||
|
||||
### react-tools
|
||||
* Added an option argument to `transform` function. The only option supported is `harmony`, which behaves the same as `jsx --harmony` on the command line. This uses the ES6 transforms from [jstransform](https://github.com/facebook/jstransform).
|
||||
127
docs/acknowledgements.md
Normal file
127
docs/acknowledgements.md
Normal file
@@ -0,0 +1,127 @@
|
||||
---
|
||||
id: acknowledgements
|
||||
title: Acknowledgements
|
||||
layout: single
|
||||
---
|
||||
|
||||
We'd like to thank all of our contributors:
|
||||
|
||||
<div class="three-column">
|
||||
<ul>
|
||||
<li>Alan deLevie</li>
|
||||
<li>Alex Zelenskiy</li>
|
||||
<li>Alexander Solovyov</li>
|
||||
<li>Andreas Svensson</li>
|
||||
<li>Andrew Davey</li>
|
||||
<li>Andrew Zich</li>
|
||||
<li>Andrey Popp</li>
|
||||
<li>Ayman Osman</li>
|
||||
<li>Ben Alpert</li>
|
||||
<li>Ben Newman</li>
|
||||
<li>Ben Ripkens</li>
|
||||
<li>Bob Eagan</li>
|
||||
<li>Brian Cooke</li>
|
||||
<li>Brian Kim</li>
|
||||
<li>Brian Rue</li>
|
||||
<li>Cam Spiers</li>
|
||||
<li>Cat Chen</li>
|
||||
<li>Cheng Lou</li>
|
||||
<li>Christian Roman</li>
|
||||
<li>Christoph Pojer</li>
|
||||
<li>Clay Allsopp</li>
|
||||
<li>Connor McSheffrey</li>
|
||||
<li>Dan Schafer</li>
|
||||
<li>Daniel Gasienica</li>
|
||||
<li>Daniel Lo Nigro</li>
|
||||
<li>Daniel Miladinov</li>
|
||||
<li>Danny Ben-David</li>
|
||||
<li>David Hellsing</li>
|
||||
<li>David Hu</li>
|
||||
<li>Dustin Getz</li>
|
||||
<li>Eric Clemmons</li>
|
||||
<li>Eric Schoffstall</li>
|
||||
<li>Fabio M. Costa</li>
|
||||
<li>Felipe Oliveira Carvalho</li>
|
||||
<li>Felix Kling</li>
|
||||
<li>Fernando Correia</li>
|
||||
<li>Greg Roodt</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>Guido Bouman</li>
|
||||
<li>Harry Hull</li>
|
||||
<li>Hugo Jobling</li>
|
||||
<li>Ian Obermiller</li>
|
||||
<li>Ingvar Stepanyan</li>
|
||||
<li>Isaac Salier-Hellendag</li>
|
||||
<li>Ivan Kozik</li>
|
||||
<li>Jakub Malinowski</li>
|
||||
<li>James Ide</li>
|
||||
<li>Jamie Wong</li>
|
||||
<li>Jamison Dance</li>
|
||||
<li>Jan Kassens</li>
|
||||
<li>Jared Forsyth</li>
|
||||
<li>Jason Bonta</li>
|
||||
<li>Jason Trill</li>
|
||||
<li>Jean Lauliac</li>
|
||||
<li>Jeff Morrison</li>
|
||||
<li>Jeffrey Lin</li>
|
||||
<li>Jignesh Kakadiya</li>
|
||||
<li>Johannes Baiter</li>
|
||||
<li>John Watson</li>
|
||||
<li>Jonas Gebhardt</li>
|
||||
<li>Jonathan Hsu</li>
|
||||
<li>Jordan Walke</li>
|
||||
<li>Josh Duck</li>
|
||||
<li>Jun Wu</li>
|
||||
<li>Keito Uchiyama</li>
|
||||
<li>Kit Randel</li>
|
||||
<li>Kunal Mehta</li>
|
||||
<li>Laurence Rowe</li>
|
||||
<li>Levi McCallum</li>
|
||||
<li>Logan Allen</li>
|
||||
<li>Luigy Leon</li>
|
||||
<li>Mark Richardson</li>
|
||||
<li>Marshall Roch</li>
|
||||
<li>Martin Andert</li>
|
||||
<li>Martin Konicek</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li>Mathieu M-Gosselin</li>
|
||||
<li>Matt Harrison</li>
|
||||
<li>Matti Nelimarkka</li>
|
||||
<li>Michal Srb</li>
|
||||
<li>Mouad Debbar</li>
|
||||
<li>Nadeesha Cabral</li>
|
||||
<li>Nicholas Bergson-Shilcock</li>
|
||||
<li>Nick Gavalas</li>
|
||||
<li>Nick Thompson</li>
|
||||
<li>Owen Coutts</li>
|
||||
<li>Pascal Hartig</li>
|
||||
<li>Paul O’Shannessy</li>
|
||||
<li>Paul Seiffert</li>
|
||||
<li>Paul Shen</li>
|
||||
<li>Pete Hunt</li>
|
||||
<li>Peter Cottle</li>
|
||||
<li>Petri Lievonen</li>
|
||||
<li>Pieter Vanderwerff</li>
|
||||
<li>Richard D. Worth</li>
|
||||
<li>Richard Feldman</li>
|
||||
<li>Richard Livesey</li>
|
||||
<li>Sander Spies</li>
|
||||
<li>Sean Kinsey</li>
|
||||
<li>Sebastian Markbåge</li>
|
||||
<li>Shaun Trennery</li>
|
||||
<li>Simon Højberg</li>
|
||||
<li>Stoyan Stefanov</li>
|
||||
<li>Sundeep Malladi</li>
|
||||
<li>Thomas Aylott</li>
|
||||
<li>Timothy Yung</li>
|
||||
<li>Tom Occhino</li>
|
||||
<li>Vjeux</li>
|
||||
<li>Wincent Colaiuta</li>
|
||||
<li>Zach Bruggeman</li>
|
||||
<li>imagentleman</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
In addition, we're grateful to [Jeff Barczewski](https://github.com/jeffbski) for allowing us to use the `react` package name on npm.
|
||||
15
docs/blog/all.html
Normal file
15
docs/blog/all.html
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: Blog
|
||||
layout: default
|
||||
sectionid: blog
|
||||
id: all-posts
|
||||
---
|
||||
|
||||
<section class="content wrap documentationContent nosidebar">
|
||||
<div class="inner-content">
|
||||
<h1>All Posts</h1>
|
||||
{% for page in site.posts %}
|
||||
<p><strong><a href="/react{{ page.url }}">{{ page.title }}</a></strong> on {{ page.date | date: "%B %e, %Y" }} by {{ page.author }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
@@ -7,22 +7,28 @@ sectionid: blog
|
||||
<section class="content wrap blogContent">
|
||||
{% include nav_blog.html %}
|
||||
<div class="inner-content">
|
||||
{% for page in site.posts %}
|
||||
{% for page in paginator.posts %}
|
||||
<div class="post-list-item">
|
||||
<h1><a href="/react{{ page.url }}">{{ page.title }}</a></h1>
|
||||
<p class="meta">{{ page.date | date: "%B %e, %Y" }} by {{ page.author }}</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<hr />
|
||||
<div class="post">
|
||||
{{ page.excerpt }}
|
||||
{% if page.excerpt != page.content %}
|
||||
<p>
|
||||
<a href="/react{{ page.url }}">Continue Reading →</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
{{ page.content }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<div class="pagination">
|
||||
{% if paginator.previous_page %}
|
||||
<a href="/react/{{ paginator.previous_page_path }}" class="previous">
|
||||
« Previous Page
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if paginator.next_page %}
|
||||
<a href="/react{{ paginator.next_page_path }}" class="next">
|
||||
Next Page »
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -19,7 +19,7 @@ Let's look at a really simple example. Create a `hello-react.html` file with the
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello React</title>
|
||||
<script src="http://fb.me/react-{{site.react_version}}.min.js"></script>
|
||||
<script src="http://fb.me/react-{{site.react_version}}.js"></script>
|
||||
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -84,8 +84,8 @@ We've found that the best solution for this problem is to generate markup direct
|
||||
|
||||
**JSX lets you write JavaScript function calls with HTML syntax.** To generate a link in React using pure JavaScript you'd write: `React.DOM.a({href: 'http://facebook.github.io/react/'}, 'Hello React!')`. With JSX this becomes `<a href="http://facebook.github.io/react/">Hello React!</a>`. We've found this has made building React apps easier and designers tend to prefer the syntax, but everyone has their own workflow, so **JSX is not required to use React.**
|
||||
|
||||
JSX is very small; the "hello, world" example above uses every feature of JSX. To learn more about it, see [JSX in depth](./jsx-in-depth.html). Or see the transform in action in [our live JSX compiler](/react/jsx-compiler.html).
|
||||
JSX is very small; the "hello, world" example above uses every feature of JSX. To learn more about it, see [JSX in depth](/react/docs/jsx-in-depth.html). Or see the transform in action in [our live JSX compiler](/react/jsx-compiler.html).
|
||||
|
||||
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](./jsx-gotchas.html) for some key differences.
|
||||
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](/react/docs/jsx-gotchas.html) for some key differences.
|
||||
|
||||
The easiest way to get started with JSX is to use the in-browser `JSXTransformer`. We strongly recommend that you don't use this in production. You can precompile your code using our command-line [react-tools](http://npmjs.org/package/react-tools) package.
|
||||
|
||||
@@ -10,6 +10,11 @@ next: jsx-gotchas.html
|
||||
JSX is a JavaScript XML syntax transform recommended for use
|
||||
with React.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> Don't forget the `/** @jsx React.DOM */` pragma at the beginning of your file! This tells JSX to process the file for React.
|
||||
>
|
||||
> If you don't include the pragma, your source will remain untouched, so it's safe to run the JSX transformer on all JS files in your codebase if you want to.
|
||||
|
||||
## Why JSX?
|
||||
|
||||
@@ -53,9 +58,11 @@ var app = Nav({color:"blue"}, Profile(null, "click"));
|
||||
```
|
||||
|
||||
Use the [JSX Compiler](/react/jsx-compiler.html) to try out JSX and see how it
|
||||
desugars into native JavaScript.
|
||||
desugars into native JavaScript, and the
|
||||
[HTML to JSX converter](/react/html-jsx.html) to convert your existing HTML to
|
||||
JSX.
|
||||
|
||||
If you want to use JSX, the [Getting Started](getting-started.html) guide shows
|
||||
If you want to use JSX, the [Getting Started](/react/docs/getting-started.html) guide shows
|
||||
how to setup compilation.
|
||||
|
||||
> Note:
|
||||
@@ -82,7 +89,7 @@ var div = React.DOM.div;
|
||||
var app = <div className="appClass">Hello, React!</div>;
|
||||
```
|
||||
|
||||
### React Component Components
|
||||
### React Composite Components
|
||||
|
||||
To construct an instance of a composite component, create a variable that
|
||||
references the class.
|
||||
@@ -92,7 +99,10 @@ var MyComponent = React.createClass({/*...*/});
|
||||
var app = <MyComponent someProperty={true} />;
|
||||
```
|
||||
|
||||
See [Component Basics](component-basics.html) to learn more about components.
|
||||
JSX will infer the component's name from the variable assignment and specify
|
||||
the class's [displayName](/react/docs/component-specs.html#displayName) accordingly.
|
||||
|
||||
See [Multiple Components](/react/docs/multiple-components.html) to learn more about using composite components.
|
||||
|
||||
> Note:
|
||||
>
|
||||
@@ -157,14 +167,6 @@ It's easy to add comments within your JSX; they're just JS expressions:
|
||||
var content = <Container>{/* this is a comment */}<Nav /></Container>;
|
||||
```
|
||||
|
||||
## Tooling
|
||||
|
||||
Beyond the compilation step, JSX does not require any special tools.
|
||||
|
||||
* Many editors already include reasonable support for JSX (Vim, Emacs js2-mode).
|
||||
* Linting provides accurate line numbers after compiling without sourcemaps.
|
||||
* Elements use standard scoping so linters can find usage of out-of-scope
|
||||
components.
|
||||
|
||||
## Prior Work
|
||||
|
||||
@@ -176,4 +178,4 @@ efforts include:
|
||||
* JSX neither provides nor requires a runtime library.
|
||||
* JSX does not alter or add to the semantics of JavaScript.
|
||||
|
||||
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](./jsx-gotchas.html) for some key differences.
|
||||
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](/react/docs/jsx-gotchas.html) for some key differences.
|
||||
|
||||
@@ -9,17 +9,9 @@ next: interactivity-and-dynamic-uis.html
|
||||
|
||||
JSX looks like HTML but there are some important differences you may run into.
|
||||
|
||||
|
||||
## Whitespace Removal
|
||||
|
||||
JSX doesn't follow the same whitespace elimination rules as HTML. JSX removes all whitespace between two curly braces expressions. If you want to have whitespace, simply add `{' '}`.
|
||||
|
||||
```javascript
|
||||
<div>{this.props.name} {' '} {this.props.surname}</div>
|
||||
```
|
||||
|
||||
Follow [Issue #65](https://github.com/facebook/react/issues/65) for discussion on this behavior.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> For DOM differences, such as the inline `style` attribute, check [here](/react/docs/dom-differences.html).
|
||||
|
||||
## HTML Entities
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ prev: jsx-gotchas.html
|
||||
next: multiple-components.html
|
||||
---
|
||||
|
||||
You've already [learned how to display data](./displaying-data.html) with React. Now let's look at how to make our UIs interactive.
|
||||
You've already [learned how to display data](/react/docs/displaying-data.html) with React. Now let's look at how to make our UIs interactive.
|
||||
|
||||
|
||||
## A Simple Example
|
||||
@@ -46,7 +46,7 @@ With React you simply pass your event handler as a camelCased prop similar to ho
|
||||
If you'd like to use React on a touch device (i.e. a phone or tablet), simply call `React.initializeTouchEvents(true);` to turn them on.
|
||||
|
||||
|
||||
## Under the Hood: autoBind and Event Delegation
|
||||
## Under the Hood: Autobinding and Event Delegation
|
||||
|
||||
Under the hood React does a few things to keep your code performant and easy to understand.
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ When you create a React component instance, you can include additional React com
|
||||
<Parent><Child /></Parent>
|
||||
```
|
||||
|
||||
`Parent` can read its children by accessing the special `this.props.children` prop.
|
||||
`Parent` can read its children by accessing the special `this.props.children` prop. **`this.props.children` is an opaque data structure:** use the [React.Children utilities](/react/docs/top-level-api.html#react.children) to manipulate them.
|
||||
|
||||
|
||||
### Child Reconciliation
|
||||
@@ -124,7 +124,7 @@ The situation gets more complicated when the children are shuffled around (as in
|
||||
var results = this.props.results;
|
||||
return (
|
||||
<ol>
|
||||
{this.results.map(function(result) {
|
||||
{results.map(function(result) {
|
||||
return <li key={result.id}>{result.text}</li>;
|
||||
})}
|
||||
</ol>
|
||||
@@ -134,6 +134,26 @@ The situation gets more complicated when the children are shuffled around (as in
|
||||
|
||||
When React reconciles the keyed children, it will ensure that any child with `key` will be reordered (instead of clobbered) or destroyed (instead of reused).
|
||||
|
||||
You can also key children by passing an object. The object keys will be used as `key` for each value. However it is important to remember that JavaScript does not guarantee the ordering of properties will be preserved. In practice browsers will preserve property order **except** for properties that can be parsed as a 32-bit unsigned integers. Numeric properties will be ordered sequentially and before other properties. If this happens React will render components out of order. This can be avoided by adding a string prefix to the key:
|
||||
|
||||
```javascript
|
||||
render: function() {
|
||||
var items = {};
|
||||
|
||||
this.props.results.forEach(function(result) {
|
||||
// If result.id can look like a number (consider short hashes), then
|
||||
// object iteration order is not guaranteed. In this case, we add a prefix
|
||||
// to ensure the keys are strings.
|
||||
items['result-' + result.id] = <li>{result.text}</li>;
|
||||
});
|
||||
|
||||
return (
|
||||
<ol>
|
||||
{items}
|
||||
</ol>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Data Flow
|
||||
|
||||
@@ -144,7 +164,7 @@ In React, data flows from owner to owned component through `props` as discussed
|
||||
|
||||
You may be thinking that it's expensive to react to changing data if there are a large number of nodes under an owner. The good news is that JavaScript is fast and `render()` methods tend to be quite simple, so in most applications this is extremely fast. Additionally, the bottleneck is almost always the DOM mutation and not JS execution and React will optimize this for you using batching and change detection.
|
||||
|
||||
However, sometimes you really want to have fine-grained control over your performance. In that case, simply override `shouldComponentUpdate()` to return false when you want React to skip processing of a subtree. See [the React reference docs](./reference.html) for more information.
|
||||
However, sometimes you really want to have fine-grained control over your performance. In that case, simply override `shouldComponentUpdate()` to return false when you want React to skip processing of a subtree. See [the React reference docs](/react/docs/component-specs.html) for more information.
|
||||
|
||||
> Note:
|
||||
>
|
||||
|
||||
@@ -12,7 +12,7 @@ When designing interfaces, break down the common design elements (buttons, form
|
||||
|
||||
## Prop Validation
|
||||
|
||||
As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify `propTypes`. `React.PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, an error will be thrown. Here is an example documenting the different validators provided:
|
||||
As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify `propTypes`. `React.PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. Note that for performance reasons `propTypes` is only checked in development mode. Here is an example documenting the different validators provided:
|
||||
|
||||
```javascript
|
||||
React.createClass({
|
||||
@@ -26,22 +26,48 @@ React.createClass({
|
||||
optionalObject: React.PropTypes.object,
|
||||
optionalString: React.PropTypes.string,
|
||||
|
||||
// You can ensure that your prop is limited to specific values by treating
|
||||
// it as an enum.
|
||||
optionalEnum: React.PropTypes.oneOf(['News','Photos']),
|
||||
// Anything that can be rendered: numbers, strings, components or an array
|
||||
// containing these types.
|
||||
optionalRenderable: React.PropTypes.renderable,
|
||||
|
||||
// A React component.
|
||||
optionalComponent: React.PropTypes.component,
|
||||
|
||||
// You can also declare that a prop is an instance of a class. This uses
|
||||
// JS's instanceof operator.
|
||||
someClass: React.PropTypes.instanceOf(SomeClass),
|
||||
optionalMessage: React.PropTypes.instanceOf(Message),
|
||||
|
||||
// You can chain any of the above with isRequired to make sure an error is
|
||||
// thrown if the prop isn't provided.
|
||||
requiredFunc: React.PropTypes.func.isRequired
|
||||
// You can ensure that your prop is limited to specific values by treating
|
||||
// it as an enum.
|
||||
optionalEnum: React.PropTypes.oneOf(['News', 'Photos']),
|
||||
|
||||
// An object that could be one of many types
|
||||
optionalUnion: React.PropTypes.oneOfType([
|
||||
React.PropTypes.string,
|
||||
React.PropTypes.number,
|
||||
React.PropTypes.instanceOf(Message)
|
||||
]),
|
||||
|
||||
// An array of a certain type
|
||||
optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.number),
|
||||
|
||||
// An object taking on a particular shape
|
||||
optionalObjectWithShape: React.PropTypes.shape({
|
||||
color: React.PropTypes.string,
|
||||
fontSize: React.PropTypes.number
|
||||
}),
|
||||
|
||||
// You can chain any of the above with isRequired to make sure a warning is
|
||||
// shown if the prop isn't provided.
|
||||
requiredFunc: React.PropTypes.func.isRequired,
|
||||
|
||||
// An object of any kind
|
||||
requiredAny: React.PropTypes.any.isRequired,
|
||||
|
||||
// You can also specify a custom validator.
|
||||
customProp: function(props, propName, componentName) {
|
||||
if (!/matchme/.test(props[propName])) {
|
||||
throw new Error('Validation failed!')
|
||||
console.warn('Validation failed!');
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -91,12 +117,32 @@ React.renderComponent(
|
||||
);
|
||||
```
|
||||
|
||||
## Single Child
|
||||
|
||||
With `React.PropTypes.component` you can specify that only a single child can be passed to
|
||||
a component as children.
|
||||
|
||||
```javascript
|
||||
var MyComponent = React.createClass({
|
||||
propTypes: {
|
||||
children: React.PropTypes.component.isRequired
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return
|
||||
<div>
|
||||
{this.props.children} // This must be exactly one element or it will throw.
|
||||
</div>;
|
||||
}
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
## Mixins
|
||||
|
||||
Components are the best way to reuse code in React, but sometimes very different components may share some common functionality. These are sometimes called [cross-cutting concerns](http://en.wikipedia.org/wiki/Cross-cutting_concern). React provides `mixins` to solve this problem.
|
||||
|
||||
One common use case is a component wanting to update itself on a time interval. It's easy to use `setInterval()`, but it's important to cancel your interval when you don't need it anymore to save memory. React provides [lifecycle methods](./working-with-the-browser.html) that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy `setInterval()` function that will automatically get cleaned up when your component is destroyed.
|
||||
One common use case is a component wanting to update itself on a time interval. It's easy to use `setInterval()`, but it's important to cancel your interval when you don't need it anymore to save memory. React provides [lifecycle methods](/react/docs/working-with-the-browser.html#component-lifecycle) that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy `setInterval()` function that will automatically get cleaned up when your component is destroyed.
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
@@ -87,7 +87,7 @@ If you want to initialize the component with a non-empty value, you can supply a
|
||||
|
||||
This example will function much like the **Controlled Components** example above.
|
||||
|
||||
Likewise, `<input>` supports `defaultChecked` and `<option>` supports `defaultSelected`.
|
||||
Likewise, `<input>` supports `defaultChecked` and `<select>` supports `defaultValue`.
|
||||
|
||||
|
||||
## Advanced Topics
|
||||
@@ -130,3 +130,18 @@ For HTML, this easily allows developers to supply multiline values. However, sin
|
||||
```
|
||||
|
||||
If you *do* decide to use children, they will behave like `defaultValue`.
|
||||
|
||||
|
||||
### Why Select Value?
|
||||
|
||||
The selected `<option>` in an HTML `<select>` is normally specified through that option's `selected` attribute. In React, in order to make components easier to manipulate, the following format is adopted instead:
|
||||
|
||||
```javascript
|
||||
<select value="B">
|
||||
<option value="A">Apple</option>
|
||||
<option value="B">Banana</option>
|
||||
<option value="C">Cranberry</option>
|
||||
</select>
|
||||
```
|
||||
|
||||
To make an uncontrolled component, `defaultValue` is used instead.
|
||||
|
||||
@@ -10,7 +10,7 @@ next: more-about-refs.html
|
||||
React provides powerful abstractions that free you from touching the DOM directly in most cases, but sometimes you simply need to access the underlying API, perhaps to work with a third-party library or existing code.
|
||||
|
||||
|
||||
## The Mock DOM
|
||||
## The Virtual DOM
|
||||
|
||||
React is so fast because it never talks to the DOM directly. React maintains a fast in-memory representation of the DOM. `render()` methods return a *description* of the DOM, and React can diff this description with the in-memory representation to compute the fastest way to update the browser.
|
||||
|
||||
@@ -62,7 +62,7 @@ React.renderComponent(
|
||||
|
||||
## More About Refs
|
||||
|
||||
To learn more about refs, including ways to use them effectively, see our [more about refs](./more-about-refs.html) documentation.
|
||||
To learn more about refs, including ways to use them effectively, see our [more about refs](/react/docs/more-about-refs.html) documentation.
|
||||
|
||||
|
||||
## Component Lifecycle
|
||||
@@ -80,7 +80,7 @@ React provides lifecycle methods that you can specify to hook into this process.
|
||||
|
||||
* `getInitialState(): object` is invoked before a component is mounted. Stateful components should implement this and return the initial state data.
|
||||
* `componentWillMount()` is invoked immediately before mounting occurs.
|
||||
* `componentDidMount(DOMElement rootNode)` is invoked immediately after mounting occurs. Initialization that requires DOM nodes should go here.
|
||||
* `componentDidMount()` is invoked immediately after mounting occurs. Initialization that requires DOM nodes should go here.
|
||||
|
||||
|
||||
### Updating
|
||||
@@ -88,7 +88,7 @@ React provides lifecycle methods that you can specify to hook into this process.
|
||||
* `componentWillReceiveProps(object nextProps)` is invoked when a mounted component receives new props. This method should be used to compare `this.props` and `nextProps` to perform state transitions using `this.setState()`.
|
||||
* `shouldComponentUpdate(object nextProps, object nextState): boolean` is invoked when a component decides whether any changes warrant an update to the DOM. Implement this as an optimization to compare `this.props` with `nextProps` and `this.state` with `nextState` and return false if React should skip updating.
|
||||
* `componentWillUpdate(object nextProps, object nextState)` is invoked immediately before updating occurs. You cannot call `this.setState()` here.
|
||||
* `componentDidUpdate(object prevProps, object prevState, DOMElement rootNode)` is invoked immediately after updating occurs.
|
||||
* `componentDidUpdate(object prevProps, object prevState)` is invoked immediately after updating occurs.
|
||||
|
||||
|
||||
### Unmounting
|
||||
@@ -103,12 +103,6 @@ _Mounted_ composite components also support the following methods:
|
||||
* `getDOMNode(): DOMElement` can be invoked on any mounted component in order to obtain a reference to its rendered DOM node.
|
||||
* `forceUpdate()` can be invoked on any mounted component when you know that some deeper aspect of the component's state has changed without using `this.setState()`.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> The `DOMElement rootNode` argument of `componentDidMount()` and
|
||||
> `componentDidUpdate()` is a convenience. The same node can be obtained by
|
||||
> calling `this.getDOMNode()`.
|
||||
|
||||
|
||||
## Browser Support and Polyfills
|
||||
|
||||
@@ -119,14 +113,35 @@ In addition to that philosophy, we've also taken the stance that we, as authors
|
||||
|
||||
### Polyfills Needed to Support Older Browsers
|
||||
|
||||
`es5-shim.js` from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim) provides the following that React needs:
|
||||
|
||||
* `Array.isArray`
|
||||
* `Array.prototype.forEach`
|
||||
* `Array.prototype.indexOf`
|
||||
* `Function.prototype.bind`
|
||||
* `Array.prototype.some`
|
||||
* `Date.now`
|
||||
* `Array.prototype.some` (also in `es5-shim.js`)
|
||||
* `Function.prototype.bind`
|
||||
* `Object.keys`
|
||||
|
||||
All of these can be polyfilled using `es5-shim.js` from [https://github.com/kriskowal/es5-shim](https://github.com/kriskowal/es5-shim).
|
||||
`es5-sham.js`, also from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim), provides the following that React needs:
|
||||
|
||||
* `console.*` - Only needed when not using the minified build. If you need to polyfill this, try [https://github.com/paulmillr/console-polyfill](https://github.com/paulmillr/console-polyfill).
|
||||
* `Object.create` - Provided in `es5-sham.js` @ [https://github.com/kriskowal/es5-shim](https://github.com/kriskowal/es5-shim).
|
||||
* `Object.create`
|
||||
|
||||
The unminified build of React needs the following from [paulmillr's console-polyfill](https://github.com/paulmillr/console-polyfill).
|
||||
|
||||
* `console.*`
|
||||
|
||||
When using HTML5 elements in IE8 including `<section>`, `<article>`, `<nav>`, `<header>`, and `<footer>`, it's also necessary to include [html5shiv](https://github.com/aFarkas/html5shiv) or a similar script.
|
||||
|
||||
|
||||
### Cross-browser Issues
|
||||
|
||||
Although React is pretty good at abstracting browser differences, some browsers are limited or present quirky behaviors that we couldn't find a workaround for.
|
||||
|
||||
|
||||
#### onScroll event on IE8
|
||||
|
||||
On IE8 the `onScroll` event doesn't bubble and IE8 doesn't have an API to define handlers to the capturing phase of an event, meaning there is no way for React to listen to these events.
|
||||
Currently a handler to this event is ignored on IE8.
|
||||
|
||||
See the [onScroll doesn't work in IE8](https://github.com/facebook/react/issues/631) GitHub issue for more information.
|
||||
|
||||
@@ -39,7 +39,7 @@ Consider the case when you wish to tell an `<input />` element (that exists with
|
||||
```
|
||||
|
||||
|
||||
Notice how, in this example, we want to "tell" the input something - something that it cannot infer from it's props over time. In this case we want to "tell" it that it should now become focused. However, there are some challenges. What is returned from `render()`` is not your actual composition of "child" components, it is merely a *description* of the children at a particular instance in time - a snapshot, if you will.
|
||||
Notice how, in this example, we want to "tell" the input something - something that it cannot infer from its props over time. In this case we want to "tell" it that it should now become focused. However, there are some challenges. What is returned from `render()` is not your actual composition of "child" components, it is merely a *description* of the children at a particular instance in time - a snapshot, if you will.
|
||||
|
||||
> Note:
|
||||
>
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
---
|
||||
id: tooling-integration
|
||||
title: Tooling integration
|
||||
title: Tooling Integration
|
||||
layout: docs
|
||||
permalink: tooling-integration.html
|
||||
prev: more-about-refs.html
|
||||
next: reference.html
|
||||
next: addons.html
|
||||
---
|
||||
|
||||
Every project uses a different system for building and deploying JavaScript. We've tried to make React as environment-agnostic as possible.
|
||||
|
||||
## React
|
||||
|
||||
## CDN-hosted React
|
||||
### CDN-hosted React
|
||||
|
||||
We provide CDN-hosted versions of React [on our download page](/react/downloads.html). These prebuilt files use the UMD module format. Dropping them in with a simple `<script>` tag will inject a `React` global into your environment. It should also work out-of-the-box in CommonJS and AMD environments.
|
||||
|
||||
|
||||
## Using master
|
||||
### Using master
|
||||
|
||||
We have instructions for building from `master` [in our GitHub repository](https://github.com/facebook/react). We build a tree of CommonJS modules under `build/modules` which you can drop into any environment or packaging tool that supports CommonJS.
|
||||
|
||||
## JSX
|
||||
|
||||
## In-browser JSX Transform
|
||||
### In-browser JSX Transform
|
||||
|
||||
If you like using JSX, we provide an in-browser JSX transformer for development [on our download page](/react/downloads.html). Simply include a `<script type="text/jsx">` tag to engage the JSX transformer. Be sure to include the `/** @jsx React.DOM */` comment as well, otherwise the transformer will not run the transforms.
|
||||
|
||||
@@ -29,16 +31,21 @@ If you like using JSX, we provide an in-browser JSX transformer for development
|
||||
> The in-browser JSX transformer is fairly large and results in extraneous computation client-side that can be avoided. Do not use it in production — see the next section.
|
||||
|
||||
|
||||
## Productionizing: Precompiled JSX
|
||||
### Productionizing: Precompiled JSX
|
||||
|
||||
If you have [npm](http://npmjs.org/), you can simply run `npm install -g react-tools` to install our command-line `jsx` tool. This tool will translate files that use JSX syntax to plain JavaScript files that can run directly in the browser. It will also watch directories for you and automatically transform files when they are changed; for example: `jsx --watch src/ build/`. Run `jsx --help` for more information on how to use this tool.
|
||||
|
||||
|
||||
## Helpful Open-Source Projects
|
||||
### Helpful Open-Source Projects
|
||||
|
||||
The open-source community has built tools that integrate JSX with several build systems.
|
||||
The open-source community has built tools that integrate JSX with several build systems. See [JSX integrations](/react/docs/complementary-tools.html#jsx-integrations) for the full list.
|
||||
|
||||
* [reactify](https://github.com/andreypopp/reactify) - use JSX with [browserify](http://browserify.org/).
|
||||
* [grunt-react](https://github.com/ericclemmons/grunt-react) - [grunt](http://gruntjs.com/) task for JSX
|
||||
* [require-jsx](https://github.com/seiffert/require-jsx) - use JSX with [require.js](http://requirejs.org/)
|
||||
* [reactapp](https://github.com/jordwalke/reactapp) - a sample project to get up-and-running with React quickly
|
||||
|
||||
### Syntax Highlighting & Linting
|
||||
|
||||
* Many editors already include reasonable support for JSX (Vim, Emacs js2-mode).
|
||||
* [JSX syntax highlighting](https://github.com/yungsters/sublime/blob/master/tmLanguage/JavaScript%20(JSX\).tmLanguage) is available for Sublime Text and other editors
|
||||
that support `*.tmLanguage`.
|
||||
* [web-mode.el](http://web-mode.org) is an autonomous emacs major mode that indents and highlights JSX
|
||||
* Linting provides accurate line numbers after compiling without sourcemaps.
|
||||
* Elements use standard scoping so linters can find usage of out-of-scope components.
|
||||
|
||||
17
docs/docs/09-addons.md
Normal file
17
docs/docs/09-addons.md
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
id: addons
|
||||
title: Add-ons
|
||||
layout: docs
|
||||
permalink: addons.html
|
||||
prev: tooling-integration.html
|
||||
next: animation.html
|
||||
---
|
||||
|
||||
`React.addons` is where we park some useful utilities for building React apps. **These should be considered experimental** but will eventually be rolled into core or a blessed utilities library:
|
||||
|
||||
- [`ReactTransitions`](animation.html), for dealing with animations and transitions that are usually not simple to implement, such as before a component's removal.
|
||||
- [`ReactLink`](two-way-binding-helpers.html), to simplify the coordination between user's form input data and and the component's state.
|
||||
- [`classSet`](class-name-manipulation.html), for manipulating the DOM `class` string a bit more cleanly.
|
||||
- [`ReactTestUtils`](test-utils.html), simple helpers for writing test cases (unminified build only).
|
||||
|
||||
To get the add-ons, use `react-with-addons.js` (and its minified counterpart) rather than the common `react.js`.
|
||||
@@ -1,209 +0,0 @@
|
||||
---
|
||||
id: reference
|
||||
title: Reference
|
||||
layout: docs
|
||||
permalink: reference.html
|
||||
prev: tooling-integration.html
|
||||
---
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
### Production Apps
|
||||
|
||||
* All of [Instagram.com](http://instagram.com/) is built on React.
|
||||
* Many components on [Facebook.com](http://www.facebook.com/), including the commenting interface, ads creation flows, and page insights.
|
||||
* [Khan Academy](http://khanacademy.org/) is using React for its question editor.
|
||||
|
||||
|
||||
### Sample Code
|
||||
|
||||
* We've included [a step-by-step comment box tutorial](./tutorial.html).
|
||||
* [The React starter kit](/react/downloads.html) includes several examples which you can [view online in our GitHub repository](https://github.com/facebook/react/tree/master/examples/).
|
||||
* [reactapp](https://github.com/jordwalke/reactapp) is a simple app template to get you up-and-running quickly with React.
|
||||
* [React one-hour email](https://github.com/petehunt/react-one-hour-email/commits/master) goes step-by-step from a static HTML mock to an interactive email reader (written in just one hour!)
|
||||
* [Rendr + React app template](https://github.com/petehunt/rendr-react-template/) demonstrates how to use React's server rendering capabilities.
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### React
|
||||
|
||||
`React` is the entry point to the React framework. If you're using one of the prebuilt packages it's available as a global; if you're using CommonJS modules you can `require()` it.
|
||||
|
||||
|
||||
#### React.DOM
|
||||
|
||||
`React.DOM` provides all of the standard HTML tags needed to build a React app. You generally don't use it directly; instead, just include it as part of the `/** @jsx React.DOM */` docblock.
|
||||
|
||||
|
||||
#### React.initializeTouchEvents
|
||||
|
||||
```javascript
|
||||
initializeTouchEvents(boolean shouldUseTouch)
|
||||
```
|
||||
|
||||
Configure React's event system to handle touch events on mobile devices.
|
||||
|
||||
|
||||
#### React.createClass
|
||||
|
||||
```javascript
|
||||
function createClass(object specification)
|
||||
```
|
||||
|
||||
Creates a component given a specification. A component implements a `render` method which returns **one single** child. That child may have an arbitrarily deep child structure. One thing that makes components different than standard prototypal classes is that you don't need to call new on them. They are convenience wrappers that construct backing instances (via new) for you.
|
||||
|
||||
|
||||
#### React.renderComponent
|
||||
|
||||
```javascript
|
||||
ReactComponent renderComponent(ReactComponent container, DOMElement container)
|
||||
```
|
||||
|
||||
Renders a React component into the DOM in the supplied `container`.
|
||||
|
||||
If the React component was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React component.
|
||||
|
||||
|
||||
#### React.unmountAndReleaseReactRootNode
|
||||
|
||||
```javascript
|
||||
unmountAndReleaseReactRootNode(DOMElement container)
|
||||
```
|
||||
|
||||
Remove a mounted React component from the DOM and clean up its event handlers and state.
|
||||
|
||||
|
||||
#### React.renderComponentToString
|
||||
|
||||
```javascript
|
||||
renderComponentToString(ReactComponent component, function callback)
|
||||
```
|
||||
|
||||
Render a component to its initial HTML. This should only be used on the server. React will call `callback` with an HTML string when the markup is ready. You can use this method to create static site generators, or you can generate HTML on the server and send it down to have a very fast initial page load. If you call `React.renderComponent()` on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.
|
||||
|
||||
|
||||
### AbstractEvent
|
||||
|
||||
Your event handlers will be passed instances of `AbstractEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event (such as `stopPropagation()` and `preventDefault()`) except they work exactly the same across all browsers.
|
||||
|
||||
If you find that you need the underlying browser event for some reason, simply use the `nativeEvent` attribute to get it.
|
||||
|
||||
|
||||
### ReactComponent
|
||||
|
||||
Component classses created by `createClass()` return instances of `ReactComponent` when called. Most of the time when you're using React you're either creating or consuming `ReactComponent`s.
|
||||
|
||||
|
||||
#### getDOMNode
|
||||
|
||||
```javascript
|
||||
DOMElement getDOMNode()
|
||||
```
|
||||
|
||||
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.
|
||||
|
||||
|
||||
#### setProps
|
||||
|
||||
```javascript
|
||||
setProps(object nextProps)
|
||||
```
|
||||
|
||||
When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `renderComponent()`. Simply call `setProps()` to change its properties and trigger a re-render.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> This method can only be called on a root-level component. That is, it's only available on the component passed directly to `renderComponent()` and none of its children. If you're inclined to use `setProps()` on a child component, instead take advantage of reactive updates and pass the new prop to the child component when it's created in `render()`.
|
||||
|
||||
|
||||
#### replaceProps
|
||||
|
||||
```javascript
|
||||
replaceProps(object nextProps)
|
||||
```
|
||||
|
||||
Like `setProps()` but deletes any pre-existing props that are not in nextProps.
|
||||
|
||||
|
||||
#### transferPropsTo
|
||||
|
||||
```javascript
|
||||
ReactComponent transferPropsTo(ReactComponent targetComponent)
|
||||
```
|
||||
|
||||
Transfer properties from this component to a target component that have not already been set on the target component. This is usually used to pass down properties to the returned root component. `targetComponent`, now updated with some new props is returned as a convenience.
|
||||
|
||||
|
||||
#### setState
|
||||
|
||||
```javascript
|
||||
setState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks. In addition, you can supply an optional callback function that is executed once `setState` is completed.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> *NEVER* mutate `this.state` directly. As calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> `setState()` does not immediately mutate `this.state` but creates a pending state transition. Accessing `this.state` after calling this method can potentially return the existing value.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> There is no guarantee of synchronous operation of calls to `setState` and calls may be batched for performance gains.
|
||||
|
||||
|
||||
#### replaceState
|
||||
|
||||
```javascript
|
||||
replaceState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Like `setState()` but deletes any pre-existing state keys that are not in nextState.
|
||||
|
||||
|
||||
#### forceUpdate()
|
||||
|
||||
```javascript
|
||||
forceUpdate([function callback])
|
||||
```
|
||||
|
||||
If your `render()` method reads from something other than `this.props` or `this.state` you'll need to tell React when it needs to re-run `render()`. Use `forceUpdate()` to cause React to automatically re-render. This will cause `render()` to be called on the component and all of its children but React will only update the DOM if the markup changes.
|
||||
|
||||
Normally you should try to avoid all uses of `forceUpdate()` and only read from `this.props` and `this.state` in `render()`. This makes your application much simpler and more efficient.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> There is no guarantee of synchronous operation of calls to `forceUpdate` and calls may be batched for performance gains.
|
||||
|
||||
|
||||
#### Lifecycle methods
|
||||
|
||||
```javascript
|
||||
object getInitialState()
|
||||
componentWillMount()
|
||||
componentDidMount(DOMElement domNode)
|
||||
componentWillReceiveProps(object nextProps)
|
||||
boolean shouldComponentUpdate(object nextProps, object nextState)
|
||||
componentWillUpdate(object nextProps, object nextState)
|
||||
ReactComponent render()
|
||||
componentDidUpdate(object prevProps, object prevState, DOMElement domNode)
|
||||
componentWillUnmount()
|
||||
```
|
||||
|
||||
See the [working with the browser](./working-with-the-browser.html) documentation for more details on these lifecycle methods.
|
||||
|
||||
|
||||
## DOM Differences
|
||||
|
||||
React has implemented a browser-independent events and DOM system for performance and cross-browser compatibility reasons. We took the opportunity to clean up a few rough edges in browser DOM implementations.
|
||||
|
||||
* All events (including submit) bubble correctly per the W3C spec
|
||||
* All event objects conform to the W3C spec
|
||||
* All DOM properties and attributes (including event handlers) should be camelCased to be consistent with standard JavaScript style. We intentionally break with the spec here, since the spec is inconsistent.
|
||||
* The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM `style` JavaScript property, is more efficient, and prevents XSS security holes.
|
||||
* `onChange` behaves as you would expect it to: whenever a form field is changed this event is fired rather than inconsistently on blur. We intentionally break from existing browser behavior because `onChange` is a misnomer for its behavior and React relies on this event to react to user input in real time.
|
||||
121
docs/docs/09.1-animation.md
Normal file
121
docs/docs/09.1-animation.md
Normal file
@@ -0,0 +1,121 @@
|
||||
---
|
||||
id: animation
|
||||
title: Animation
|
||||
layout: docs
|
||||
permalink: animation.html
|
||||
prev: addons.html
|
||||
next: two-way-binding-helpers.html
|
||||
---
|
||||
|
||||
React provides a `ReactTransitionGroup` addon component as a low-level API for animation, and a `ReactCSSTransitionGroup` for easily implementing basic CSS animations and transitions.
|
||||
|
||||
## High-level API: `ReactCSSTransitionGroup`
|
||||
|
||||
`ReactCSSTransitionGroup` is based on `ReactTransitionGroup` and is an easy way to perform CSS transitions and animations when a React component enters or leaves the DOM. It's inspired by the excellent [ng-animate](http://www.nganimate.org/) library.
|
||||
|
||||
### Getting Started
|
||||
|
||||
`ReactCSSTransitionGroup` is the interface to `ReactTransitions`. This is a simple element that wraps all of the components you are interested in animating. Here's an example where we fade list items in and out.
|
||||
|
||||
```javascript{22-24}
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
|
||||
|
||||
var TodoList = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {items: ['hello', 'world', 'click', 'me']};
|
||||
},
|
||||
handleAdd: function() {
|
||||
var newItems =
|
||||
this.state.items.concat([prompt('Enter some text')]);
|
||||
this.setState({items: newItems});
|
||||
},
|
||||
handleRemove: function(i) {
|
||||
var newItems = this.state.items;
|
||||
newItems.splice(i, 1)
|
||||
this.setState({items: newItems});
|
||||
},
|
||||
render: function() {
|
||||
var items = this.state.items.map(function(item, i) {
|
||||
return (
|
||||
<div key={item} onClick={this.handleRemove.bind(this, i)}>
|
||||
{item}
|
||||
</div>
|
||||
);
|
||||
}.bind(this));
|
||||
return (
|
||||
<div>
|
||||
<div><button onClick={this.handleAdd} /></div>
|
||||
<ReactCSSTransitionGroup transitionName="example">
|
||||
{items}
|
||||
</ReactCSSTransitionGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
In this component, when a new item is added to `ReactCSSTransitionGroup` it will get the `example-enter` CSS class and the `example-enter-active` CSS class added in the next tick. This is a convention based on the `transitionName` prop.
|
||||
|
||||
You can use these classes to trigger a CSS animation or transition. For example, try adding this CSS and adding a new list item:
|
||||
|
||||
```css
|
||||
.example-enter {
|
||||
opacity: 0.01;
|
||||
transition: opacity .5s ease-in;
|
||||
}
|
||||
|
||||
.example-enter.example-enter-active {
|
||||
opacity: 1;
|
||||
}
|
||||
```
|
||||
|
||||
You'll notice that when you try to remove an item `ReactCSSTransitionGroup` keeps it in the DOM. If you're using an unminified build of React with add-ons you'll see a warning that React was expecting an animation or transition to occur. That's because `ReactCSSTransitionGroup` keeps your DOM elements on the page until the animation completes. Try adding this CSS:
|
||||
|
||||
```css
|
||||
.example-leave {
|
||||
opacity: 1;
|
||||
transition: opacity .5s ease-in;
|
||||
}
|
||||
|
||||
.example-leave.example-leave-active {
|
||||
opacity: 0.01;
|
||||
}
|
||||
```
|
||||
|
||||
### Disabling Animations
|
||||
|
||||
You can disable animating `enter` or `leave` animations if you want. For example, sometimes you may want an `enter` animation and no `leave` animation, but `ReactCSSTransitionGroup` waits for an animation to complete before removing your DOM node. You can add `transitionEnter={false}` or `transitionLeave={false}` props to `ReactCSSTransitionGroup` to disable these animations.
|
||||
|
||||
## Low-level API: `ReactTransitionGroup`
|
||||
|
||||
`ReactTransitionGroup` is the basis for animations. When children are declaratively added or removed from it (as in the example above) special lifecycle hooks are called on them.
|
||||
|
||||
### `componentWillEnter(callback)`
|
||||
|
||||
This is called at the same time as `componentDidMount()` for components added to an existing `TransitionGroup`. It will block other animations from occurring until `callback` is called. It will not be called on the initial render of a `TransitionGroup`.
|
||||
|
||||
### `componentDidEnter()`
|
||||
|
||||
This is called after the `callback` function that was passed to `componentWillEnter` is called.
|
||||
|
||||
### `componentWillLeave(callback)`
|
||||
|
||||
This is called when the child has been removed from the `ReactTransitionGroup`. Though the child has been removed, `ReactTransitionGroup` will keep it in the DOM until `callback` is called.
|
||||
|
||||
### `componentDidLeave()`
|
||||
|
||||
This is called when the `willLeave` `callback` is called (at the same time as `componentWillUnmount`).
|
||||
|
||||
### Rendering a Different Component
|
||||
|
||||
By default `ReactTransitionGroup` renders as a `span`. You can change this behavior by providing a `component` prop. For example, here's how you would render a `<ul>`:
|
||||
|
||||
```javascript{1}
|
||||
<ReactTransitionGroup component={React.DOM.ul}>
|
||||
...
|
||||
</ReactTransitionGroup>
|
||||
```
|
||||
|
||||
Every DOM component is under `React.DOM`. However, `component` does not need to be a DOM component. It can be any React component you want; even ones you've written yourself!
|
||||
119
docs/docs/09.2-form-input-binding-sugar.md
Normal file
119
docs/docs/09.2-form-input-binding-sugar.md
Normal file
@@ -0,0 +1,119 @@
|
||||
---
|
||||
id: two-way-binding-helpers
|
||||
title: Two-Way Binding Helpers
|
||||
layout: docs
|
||||
permalink: two-way-binding-helpers.html
|
||||
prev: animation.html
|
||||
next: class-name-manipulation.html
|
||||
---
|
||||
|
||||
`ReactLink` is an easy way to express two-way binding with React.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> If you're new to the framework, note that `ReactLink` is not needed for most applications and should be used cautiously.
|
||||
|
||||
In React, data flows one way: from owner to child. This is because data only flows one direction in [the Von Neumann model of computing](http://en.wikipedia.org/wiki/Von_Neumann_architecture). You can think of it as "one-way data binding."
|
||||
|
||||
However, there are lots of applications that require you to read some data and flow it back into your program. For example, when developing forms, you'll often want to update some React `state` when you receive user input. Or perhaps you want to perform layout in JavaScript and react to changes in some DOM element size.
|
||||
|
||||
In React, you would implement this by listening to a "change" event, read from your data source (usually the DOM) and call `setState()` on one of your components. "Closing the data flow loop" explicitly leads to more understandable and easier-to-maintain programs. See [our forms documentation](/react/docs/forms.html) for more information.
|
||||
|
||||
Two-way binding -- implicitly enforcing that some value in the DOM is always consistent with some React `state` -- is concise and supports a wide variety of applications. We've provided `ReactLink`: syntactic sugar for setting up the common data flow loop pattern described above, or "linking" some data source to React `state`.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> ReactLink is just a thin wrapper and convention around the `onChange`/`setState()` pattern. It doesn't fundamentally change how data flows in your React application.
|
||||
|
||||
## ReactLink: Before and After
|
||||
|
||||
Here's a simple form example without using `ReactLink`:
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var NoLink = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {value: 'Hello!'};
|
||||
},
|
||||
handleChange: function(event) {
|
||||
this.setState({value: event.target.value});
|
||||
},
|
||||
render: function() {
|
||||
var value = this.state.value;
|
||||
return <input type="text" value={value} onChange={this.handleChange} />;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
This works really well and it's very clear how data is flowing, however with a lot of form fields it could get a bit verbose. Let's use `ReactLink` to save us some typing:
|
||||
|
||||
```javascript{4,9}
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var WithLink = React.createClass({
|
||||
mixins: [React.addons.LinkedStateMixin],
|
||||
getInitialState: function() {
|
||||
return {value: 'Hello!'};
|
||||
},
|
||||
render: function() {
|
||||
return <input type="text" valueLink={this.linkState('value')} />;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
`LinkedStateMixin` adds a method to your React component called `linkState()`. `linkState()` returns a `ReactLink` object which contains the current value of the React state and a callback to change it.
|
||||
|
||||
`ReactLink` objects can be passed up and down the tree as props, so it's easy (and explicit) to set up two-way binding between a component deep in the hierarchy and state that lives higher in the hierarchy.
|
||||
|
||||
Note that `<input>` supports ReactLink for both `value` and `checked`.
|
||||
|
||||
## Under the Hood
|
||||
|
||||
There are two sides to `ReactLink`: the place where you create the `ReactLink` instance and the place where you use it. To prove how simple `ReactLink` is, let's rewrite each side separately to be more explicit.
|
||||
|
||||
### ReactLink Without LinkedStateMixin
|
||||
|
||||
```javascript{7-9,11-14}
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var WithoutMixin = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {value: 'Hello!'};
|
||||
},
|
||||
handleChange: function(newValue) {
|
||||
this.setState({value: newValue});
|
||||
},
|
||||
render: function() {
|
||||
var valueLink = {
|
||||
value: this.state.value,
|
||||
requestChange: this.handleChange
|
||||
};
|
||||
return <input type="text" valueLink={valueLink} />;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
As you can see, `ReactLink` objects are very simple objects that just have a `value` and `requestChange` prop. And `LinkedStateMixin` is similarly simple: it just populates those fields with a value from `this.state` and a callback that calls `this.setState()`.
|
||||
|
||||
### ReactLink Without valueLink
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var WithoutLink = React.createClass({
|
||||
mixins: [React.addons.LinkedStateMixin],
|
||||
getInitialState: function() {
|
||||
return {value: 'Hello!'};
|
||||
},
|
||||
render: function() {
|
||||
var valueLink = this.linkState('value');
|
||||
var handleChange = function(e) {
|
||||
valueLink.requestChange(e.target.value);
|
||||
};
|
||||
return <input type="text" value={valueLink.value} onChange={handleChange} />;
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
The `valueLink` prop is also quite simple. It simply handles the `onChange` event and calls `this.props.valueLink.requestChange()` and also uses `this.props.valueLink.value` instead of `this.props.value`. That's it!
|
||||
46
docs/docs/09.3-class-name-manipulation.md
Normal file
46
docs/docs/09.3-class-name-manipulation.md
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
id: class-name-manipulation
|
||||
title: Class Name Manipulation
|
||||
layout: docs
|
||||
permalink: class-name-manipulation.html
|
||||
prev: two-way-binding-helpers.html
|
||||
next: test-utils.html
|
||||
---
|
||||
|
||||
`classSet()` is a neat utility for easily manipulating the DOM `class` string.
|
||||
|
||||
Here's a common scenario and its solution without `classSet()`:
|
||||
|
||||
```javascript
|
||||
// inside some `<Message />` React component
|
||||
render: function() {
|
||||
var classString = 'message';
|
||||
if (this.props.isImportant) {
|
||||
classString += ' message-important';
|
||||
}
|
||||
if (this.props.isRead) {
|
||||
classString += ' message-read';
|
||||
}
|
||||
// 'message message-important message-read'
|
||||
return <div className={classString}>Great, I'll be there.</div>;
|
||||
}
|
||||
```
|
||||
|
||||
This can quickly get tedious, as assigning class name strings can be hard to read and error-prone. `classSet()` solves this problem:
|
||||
|
||||
```javascript
|
||||
render: function() {
|
||||
var cx = React.addons.classSet;
|
||||
var classes = cx({
|
||||
'message': true,
|
||||
'message-important': this.props.isImportant,
|
||||
'message-read': this.props.isRead
|
||||
});
|
||||
// same final string, but much cleaner
|
||||
return <div className={classes}>Great, I'll be there.</div>;
|
||||
}
|
||||
```
|
||||
|
||||
When using `classSet()`, pass an object with keys of the CSS class names you might or might not need. Truthy values will result in the key being a part of the resulting string.
|
||||
|
||||
No more hacky string concatenations!
|
||||
140
docs/docs/09.4-test-utils.md
Normal file
140
docs/docs/09.4-test-utils.md
Normal file
@@ -0,0 +1,140 @@
|
||||
---
|
||||
id: test-utils
|
||||
title: Test Utilities
|
||||
layout: docs
|
||||
permalink: test-utils.html
|
||||
prev: class-name-manipulation.html
|
||||
next: clone-with-props.html
|
||||
---
|
||||
|
||||
`React.addons.TestUtils` makes it easy to test React components in the testing framework of your choice (we use [Jasmine](http://pivotal.github.io/jasmine/) with [jsdom](https://github.com/tmpvar/jsdom)).
|
||||
|
||||
### Simulate
|
||||
|
||||
```javascript
|
||||
Simulate.{eventName}({ReactComponent|DOMElement} element, object eventData)
|
||||
```
|
||||
|
||||
Simulate an event dispatch on a React component instance or browser DOM node with optional `eventData` event data. **This is possibly the single most useful utility in `ReactTestUtils`.**
|
||||
|
||||
Example usage:
|
||||
|
||||
```javascript
|
||||
React.addons.TestUtils.Simulate.click(myComponent);
|
||||
React.addons.TestUtils.Simulate.change(myComponent);
|
||||
React.addons.TestUtils.Simulate.keydown(myComponent, {key: "Enter"});
|
||||
```
|
||||
|
||||
`Simulate` has a method for every event that React understands.
|
||||
|
||||
### renderIntoDocument
|
||||
|
||||
```javascript
|
||||
ReactComponent renderIntoDocument(ReactComponent instance)
|
||||
```
|
||||
|
||||
Render a component into a detached DOM node in the document. **This function requires a DOM.**
|
||||
|
||||
### mockComponent
|
||||
|
||||
```javascript
|
||||
object mockComponent(function componentClass, string? tagName)
|
||||
```
|
||||
|
||||
Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
|
||||
|
||||
### isComponentOfType
|
||||
|
||||
```javascript
|
||||
boolean isComponentOfType(ReactComponent instance, function componentClass)
|
||||
```
|
||||
|
||||
Returns true if `instance` is an instance of a React `componentClass`.
|
||||
|
||||
### isDOMComponent
|
||||
|
||||
```javascript
|
||||
boolean isDOMComponent(ReactComponent instance)
|
||||
```
|
||||
|
||||
Returns true if `instance` is a DOM component (such as a `<div>` or `<span>`).
|
||||
|
||||
### isCompositeComponent
|
||||
|
||||
```javascript
|
||||
boolean isCompositeComponent(ReactComponent instance)`
|
||||
```
|
||||
|
||||
Returns true if `instance` is a composite component (created with `React.createClass()`)
|
||||
|
||||
### isCompositeComponentWithType
|
||||
|
||||
```javascript
|
||||
boolean isCompositeComponentWithType(ReactComponent instance, function componentClass)
|
||||
```
|
||||
|
||||
The combination of `isComponentOfType()` and `isCompositeComponent()`.
|
||||
|
||||
### isTextComponent
|
||||
|
||||
```javascript
|
||||
boolean isTextComponent(ReactComponent instance)
|
||||
```
|
||||
|
||||
Returns true if `instance` is a plain text component.
|
||||
|
||||
### findAllInRenderedTree
|
||||
|
||||
```javascript
|
||||
array findAllInRenderedTree(ReactComponent tree, function test)
|
||||
```
|
||||
|
||||
Traverse all components in `tree` and accumulate all components where `test(component)` is true. This is not that useful on its own, but it's used as a primitive for other test utils.
|
||||
|
||||
### scryRenderedDOMComponentsWithClass
|
||||
|
||||
```javascript
|
||||
array scryRenderedDOMComponentsWithClass(ReactCompoennt tree, string className)
|
||||
```
|
||||
|
||||
Finds all instance of components in the rendered tree that are DOM components with the class name matching `className`.
|
||||
|
||||
### findRenderedDOMComponentWithClass
|
||||
|
||||
```javascript
|
||||
ReactComponent findRenderedDOMComponentWithClass(ReactComponent tree, string className)
|
||||
```
|
||||
|
||||
Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
|
||||
|
||||
### scryRenderedDOMComponentsWithTag
|
||||
|
||||
```javascript
|
||||
array scryRenderedDOMComponentsWithTag(ReactComponent tree, string tagName)
|
||||
```
|
||||
|
||||
Finds all instance of components in the rendered tree that are DOM components with the tag name matching `tagName`.
|
||||
|
||||
### findRenderedDOMComponentWithTag
|
||||
|
||||
```javascript
|
||||
ReactComponent findRenderedDOMComponentWithTag(ReactComponent tree, string tagName)
|
||||
```
|
||||
|
||||
Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
|
||||
|
||||
### scryRenderedComponentsWithType
|
||||
|
||||
```javascript
|
||||
array scryRenderedComponentsWithType(ReactComponent tree, function componentClass)
|
||||
```
|
||||
|
||||
Finds all instances of components with type equal to `componentClass`.
|
||||
|
||||
### findRenderedComponentWithType
|
||||
|
||||
```javascript
|
||||
ReactComponent findRenderedComponentWithType(ReactComponent tree, function componentClass)
|
||||
```
|
||||
|
||||
Same as `scryRenderedComponentsWithType()` but expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.
|
||||
13
docs/docs/09.5-clone-with-props.md
Normal file
13
docs/docs/09.5-clone-with-props.md
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
id: clone-with-props
|
||||
title: Cloning Components
|
||||
layout: docs
|
||||
permalink: clone-with-props.html
|
||||
prev: test-utils.html
|
||||
---
|
||||
|
||||
In rare situations a component may want to change the props of a component that it doesn't own (like changing the `className` of a component passed as `this.props.children`). Other times it may want to make multiple copies of a component passed to it. `cloneWithProps()` makes this possible.
|
||||
|
||||
#### `ReactComponent React.addons.cloneWithProps(ReactComponent component, object? extraProps)`
|
||||
|
||||
Do a shallow copy of `component` and merge any props provided by `extraProps`. Props are merged in the same manner as [`transferPropsTo()`](/react/docs/component-api.html#transferpropsto), so props like `className` will be merged intelligently.
|
||||
@@ -1,96 +0,0 @@
|
||||
---
|
||||
id: OUTLINE
|
||||
title: Goals of the documentation
|
||||
layout: docs
|
||||
prev: 09.1-tutorial.html
|
||||
---
|
||||
- Flow of docs should mimic progression of questions a new user would ask
|
||||
- High information density -- assume the reader is adept at JS
|
||||
- Talk about best practices
|
||||
- JSFiddles for all code samples
|
||||
- Provide background for some of the design decisions
|
||||
- Less words less words less words!
|
||||
|
||||
## Outline
|
||||
|
||||
Motivation / Why React?
|
||||
- Declarative (simple)
|
||||
- Components (separation of concerns)
|
||||
- Give it 5 minutes
|
||||
|
||||
Displaying data
|
||||
- Hello world example
|
||||
- Reactive updates
|
||||
- Components are just functions
|
||||
- JSX syntax (link to separate doc?)
|
||||
- JSX gotchas
|
||||
|
||||
Interactivity and dynamic UIs
|
||||
- Click handler example
|
||||
- Event handlers / synthetic events (link to w3c docs)
|
||||
- Under the hood: autoBind and event delegation (IE8 notes)
|
||||
- React is a state machine
|
||||
- How state works
|
||||
- What components should have state?
|
||||
- What should go in state?
|
||||
- What shouldn't go in state?
|
||||
|
||||
Scaling up: using multiple components
|
||||
- Motivation: separate concerns
|
||||
- Composition example
|
||||
- Ownership (and owner vs. parent)
|
||||
- Children
|
||||
- Data flow (one-way data binding)
|
||||
- A note on performance
|
||||
|
||||
Building effective reusable components
|
||||
- You should build a reusable component library (CSS, testing etc)
|
||||
- Prop validation
|
||||
- Transferring props: a shortcut
|
||||
- Mixins
|
||||
- Testing
|
||||
|
||||
Forms
|
||||
|
||||
Working with the browser
|
||||
- The mock DOM
|
||||
- Refs / getDOMNode()
|
||||
- More about refs
|
||||
- Component lifecycle
|
||||
- Browser support and polyfills
|
||||
|
||||
Working with your environment
|
||||
- CDN-hosted React
|
||||
- Using master
|
||||
- In-browser JSX transform
|
||||
- Productionizing: precompiled JSX
|
||||
- Helpful open-source projects
|
||||
|
||||
Integrating with other UI libraries
|
||||
- Using jQuery plugins
|
||||
- Letting jQuery manage React components
|
||||
- Using with Backbone.View
|
||||
- CoffeeScript
|
||||
- Moving from Handlebars to React: an example
|
||||
|
||||
Server / static rendering
|
||||
- Motivation
|
||||
- Simple example
|
||||
- How does it work? (No DOM)
|
||||
- Rendr + React
|
||||
|
||||
Big ideas
|
||||
- Animation
|
||||
- Bootstrap bindings (responsive grids)
|
||||
- Reactive CSS
|
||||
- Web workers
|
||||
- Native views
|
||||
|
||||
Case studies
|
||||
- Comment box tutorial from scratch
|
||||
- From HTML mock to application: React one-hour email
|
||||
- Jordan's LikeToggler example
|
||||
|
||||
Reference
|
||||
- API
|
||||
- DOM differences
|
||||
60
docs/docs/complementary-tools.md
Normal file
60
docs/docs/complementary-tools.md
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
id: complementary-tools
|
||||
title: Complementary Tools
|
||||
layout: docs
|
||||
permalink: complementary-tools.html
|
||||
prev: videos.html
|
||||
next: examples.html
|
||||
---
|
||||
|
||||
React is a small library that does one thing well. Here's a list of tools we've found that work really well with React when building applications.
|
||||
|
||||
If you want your project on this list, or think one of these projects should be removed, [open an issue on GitHub](https://github.com/facebook/react/issues/new).
|
||||
|
||||
### JSX integrations
|
||||
|
||||
* **[jsxhint](https://npmjs.org/package/jsxhint)** [JSHint](http://jshint.com/) (linting) support.
|
||||
* **[reactify](https://npmjs.org/package/reactify)** [Browserify](http://browserify.org/) transform.
|
||||
* **[node-jsx](https://npmjs.org/package/node-jsx)** Native [Node](http://nodejs.org/) support.
|
||||
* **[jsx-loader](https://npmjs.org/package/jsx-loader)** Loader for [webpack](http://webpack.github.io/).
|
||||
* **[grunt-react](https://npmjs.org/package/grunt-react)** [GruntJS](http://gruntjs.com/) task.
|
||||
* **[gulp-react](https://npmjs.org/package/gulp-react)** [GulpJS](http://gulpjs.com/) plugin.
|
||||
* **[jsx-requirejs-plugin](https://github.com/philix/jsx-requirejs-plugin)** [RequireJS](http://requirejs.org/) plugin.
|
||||
* **[react-meteor](https://github.com/benjamn/react-meteor)** [Meteor](http://www.meteor.com/) plugin.
|
||||
* **[pyReact](https://github.com/facebook/react-python)** [Python](http://www.python.org/) bridge to JSX.
|
||||
* **[react-rails](https://github.com/facebook/react-rails)** Ruby gem for using JSX with [Ruby on Rails](http://rubyonrails.org/).
|
||||
|
||||
### Full-stack starter kits
|
||||
|
||||
* **[react-quickstart](https://github.com/andreypopp/react-quickstart)** Quick-start template for `express`, `browserify`, `react-router-component` and `react-async` (**includes "isomorphic" server rendering**).
|
||||
* **[generator-react-webpack](https://github.com/newtriks/generator-react-webpack)** [Yeoman](http://yeoman.io/) generator for React and Webpack.
|
||||
* **[Genesis Skeleton](http://genesis-skeleton.com/)** Modern, opinionated, full-stack starter kit for rapid, streamlined application development (supports React).
|
||||
* **[react-starter-template](https://github.com/johnthethird/react-starter-template)** Starter template with Gulp, Webpack and Bootstrap.
|
||||
* **[react-brunch](https://npmjs.org/package/react-brunch)** [Brunch](http://brunch.io/) plugin.
|
||||
* **[react-browserify-template](https://github.com/petehunt/react-browserify-template)** Quick-start with Browserify.
|
||||
|
||||
### Routing
|
||||
|
||||
* **[director](https://github.com/flatiron/director)** (For an example see [TodoMVC](https://github.com/tastejs/todomvc/blob/gh-pages/architecture-examples/react/js/app.jsx#L29)).
|
||||
* **[Backbone](http://backbonejs.org/)** (For an example see [github-issues-viewer](https://github.com/jaredly/github-issues-viewer)).
|
||||
* **[react-router](https://github.com/jaredly/react-router)** (Example coming soon).
|
||||
* **[react-router-component](http://andreypopp.viewdocs.io/react-router-component)**
|
||||
|
||||
### Model management
|
||||
|
||||
* **[react.backbone](https://github.com/usepropeller/react.backbone)** Use [Backbone](http://backbonejs.org) models with React.
|
||||
* **[cortex](https://github.com/mquan/cortex/)** A JavaScript library for centrally managing data with React.
|
||||
* **[avers](https://github.com/wereHamster/avers)** A modern client-side model abstraction library.
|
||||
|
||||
### Data fetching
|
||||
|
||||
* **[react-async](http://andreypopp.viewdocs.io/react-async)** Adds a `getInitialStateAsync(cb)` method suitable for data fetching on both the client and the server.
|
||||
* **[superagent](http://visionmedia.github.io/superagent/)** A lightweight "isomorphic" library for AJAX requests.
|
||||
|
||||
### UI components
|
||||
|
||||
* **[react-bootstrap](https://github.com/stevoland/react-bootstrap)** Bootstrap 3 components built with React.
|
||||
* **[react-topcoat](https://github.com/plaxdan/react-topcoat)** Topcoat components built with React.
|
||||
* **[react-lorem-component](https://github.com/martinandert/react-lorem-component)** Lorem Ipsum placeholder component.
|
||||
* **[wingspan-forms](https://github.com/wingspan/wingspan-forms)** React library for dynamic forms & grids; widgets provided by KendoUI.
|
||||
* **[react-translate-component](https://github.com/martinandert/react-translate-component)** React component for i18n.
|
||||
29
docs/docs/examples.md
Normal file
29
docs/docs/examples.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
id: examples
|
||||
title: Examples
|
||||
layout: docs
|
||||
permalink: examples.html
|
||||
prev: complementary-tools.html
|
||||
---
|
||||
|
||||
### Production Apps
|
||||
|
||||
* **[Instagram.com](http://instagram.com/)** is 100% built on React, both public site and internal tools.
|
||||
* **[Facebook.com](http://www.facebook.com/)**'s commenting interface, business management tools, [Lookback video editor](http://facebook.com/lookback/edit), page insights, and most, if not all, new JS development.
|
||||
* **[Khan Academy](http://khanacademy.org/)** uses React for most new JS development.
|
||||
* **[Shirtstarter](https://www.shirtstarter.com/)** is 100% built on React.
|
||||
* **[Sberbank](http://sberbank.ru/moscow/ru/person/)**, Russia's number one bank, is built with React.
|
||||
* **[The New York Times's 2014 Red Carpet Project](http://www.nytimes.com/interactive/2014/02/02/fashion/red-carpet-project.html?_r=0)** is built with React.
|
||||
|
||||
### Sample Code
|
||||
|
||||
* **[React starter kit](/react/downloads.html)** Includes several examples which you can [view online in our GitHub repository](https://github.com/facebook/react/tree/master/examples/).
|
||||
* **[React one-hour email](https://github.com/petehunt/react-one-hour-email/commits/master)** Goes step-by-step from a static HTML mock to an interactive email reader, written in just one hour!
|
||||
* **[React server rendering example](https://github.com/mhart/react-server-example)** Demonstrates how to use React's server rendering capabilities.
|
||||
|
||||
### Open-Source Demos
|
||||
|
||||
* **[TodoMVC](https://github.com/tastejs/todomvc/tree/gh-pages/architecture-examples/react/js)**
|
||||
* **[Khan Academy question editor](https://github.com/khan/perseus)** (Browse their GitHub account for many more production apps!)
|
||||
* **[github-issue-viewer](https://github.com/jaredly/github-issues-viewer)**
|
||||
* **[hn-react](https://github.com/prabirshrestha/hn-react)** Dead-simple Hacker News client.
|
||||
@@ -28,7 +28,7 @@ In the root directory of the starter kit, create a `helloworld.html` with the fo
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="build/react.min.js"></script>
|
||||
<script src="build/react.js"></script>
|
||||
<script src="build/JSXTransformer.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -44,7 +44,7 @@ In the root directory of the starter kit, create a `helloworld.html` with the fo
|
||||
</html>
|
||||
```
|
||||
|
||||
The XML syntax inside of JavaScript is called JSX; check out the [JSX syntax](syntax.html) to learn more about it. In order to translate it to vanilla JavaScript we use `<script type="text/jsx">` and include `JSXTransformer.js` to actually perform the transformation in the browser.
|
||||
The XML syntax inside of JavaScript is called JSX; check out the [JSX syntax](/react/docs/jsx-in-depth.html) to learn more about it. In order to translate it to vanilla JavaScript we use `<script type="text/jsx">` and include `JSXTransformer.js` to actually perform the transformation in the browser.
|
||||
|
||||
### Separate File
|
||||
|
||||
@@ -84,13 +84,13 @@ The file `build/helloworld.js` is autogenerated whenever you make a change.
|
||||
/** @jsx React.DOM */
|
||||
React.renderComponent(
|
||||
React.DOM.h1(null, 'Hello, world!'),
|
||||
document.getElementyById('example')
|
||||
document.getElementById('example')
|
||||
);
|
||||
```
|
||||
|
||||
> Note:
|
||||
>
|
||||
> The comment parser is very strict right now, in order for it to pick up the `@jsx` modifier, two conditions are required. The `@jsx` comment block must be the first comment on the file. The comment must start with `/**` (`/*` and `//` will not work). If the parser can't find the `@jsx` comment, it will output the file without transforming it.
|
||||
> The comment parser is very strict right now; in order for it to pick up the `@jsx` modifier, two conditions are required. The `@jsx` comment block must be the first comment on the file. The comment must start with `/**` (`/*` and `//` will not work). If the parser can't find the `@jsx` comment, it will output the file without transforming it.
|
||||
|
||||
Update your HTML file as below:
|
||||
|
||||
@@ -99,7 +99,7 @@ Update your HTML file as below:
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello React!</title>
|
||||
<script src="build/react.min.js"></script>
|
||||
<script src="build/react.js"></script>
|
||||
<!-- No need for JSXTransformer! -->
|
||||
</head>
|
||||
<body>
|
||||
@@ -115,4 +115,4 @@ If you want to use React within a module system, [fork our repo](http://github.c
|
||||
|
||||
## Next Steps
|
||||
|
||||
Check out [the tutorial](tutorial.html) and the other examples in the `/examples` directory to learn more. Good luck, and welcome!
|
||||
Check out [the tutorial](/react/docs/tutorial.html) and the other examples in the `/examples` directory to learn more. Good luck, and welcome!
|
||||
|
||||
4
docs/docs/index.html
Normal file
4
docs/docs/index.html
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
layout: redirect
|
||||
destination: getting-started.html
|
||||
---
|
||||
106
docs/docs/ref-01-top-level-api.md
Normal file
106
docs/docs/ref-01-top-level-api.md
Normal file
@@ -0,0 +1,106 @@
|
||||
---
|
||||
id: top-level-api
|
||||
title: Top-Level API
|
||||
layout: docs
|
||||
permalink: top-level-api.html
|
||||
next: component-api.html
|
||||
---
|
||||
|
||||
## React
|
||||
|
||||
`React` is the entry point to the React framework. If you're using one of the prebuilt packages it's available as a global; if you're using CommonJS modules you can `require()` it.
|
||||
|
||||
|
||||
### React.Children
|
||||
|
||||
`React.Children` provides utilities for dealing with the `this.props.children` opaque data structure.
|
||||
|
||||
#### React.Children.map
|
||||
|
||||
```javascript
|
||||
object React.Children.map(object children, function fn [, object context])
|
||||
```
|
||||
|
||||
Invoke `fn` on every immediate child contained within `children` with `this` set to `context`. If `children` is a nested object or array it will be traversed: `fn` will never be passed the container objects. If children is `null` or `undefined` returns `null` or `undefined` rather than an empty object.
|
||||
|
||||
#### React.Children.forEach
|
||||
|
||||
```javascript
|
||||
React.Children.forEach(object children, function fn [, object context])
|
||||
```
|
||||
|
||||
Like `React.Children.map()` but does not return an object.
|
||||
|
||||
#### React.Children.only
|
||||
|
||||
```javascript
|
||||
object React.Children.only(object children)
|
||||
```
|
||||
|
||||
Return the only child in `children`. Throws otherwise.
|
||||
|
||||
|
||||
### React.DOM
|
||||
|
||||
`React.DOM` provides all of the standard HTML tags needed to build a React app. You generally don't use it directly; instead, just include it as part of the `/** @jsx React.DOM */` docblock.
|
||||
|
||||
|
||||
### React.initializeTouchEvents
|
||||
|
||||
```javascript
|
||||
initializeTouchEvents(boolean shouldUseTouch)
|
||||
```
|
||||
|
||||
Configure React's event system to handle touch events on mobile devices.
|
||||
|
||||
|
||||
### React.createClass
|
||||
|
||||
```javascript
|
||||
function createClass(object specification)
|
||||
```
|
||||
|
||||
Create a component given a specification. A component implements a `render` method which returns **one single** child. That child may have an arbitrarily deep child structure. One thing that makes components different than standard prototypal classes is that you don't need to call new on them. They are convenience wrappers that construct backing instances (via new) for you.
|
||||
|
||||
For more information about the specification object, see [Component Specs and Lifecycle](/react/docs/component-specs.html).
|
||||
|
||||
|
||||
### React.renderComponent
|
||||
|
||||
```javascript
|
||||
ReactComponent renderComponent(
|
||||
ReactComponent component,
|
||||
DOMElement container,
|
||||
[function callback]
|
||||
)
|
||||
```
|
||||
|
||||
Render a React component into the DOM in the supplied `container` and return a reference to the component.
|
||||
|
||||
If the React component was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React component.
|
||||
|
||||
If the optional callback is provided, it will be executed after the component is rendered or updated.
|
||||
|
||||
|
||||
### React.unmountComponentAtNode
|
||||
|
||||
```javascript
|
||||
boolean unmountComponentAtNode(DOMElement container)
|
||||
```
|
||||
|
||||
Remove a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing. Returns `true` if a component was unmounted and `false` if there was no component to unmount.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> This method was called `React.unmountAndReleaseReactRootNode` until v0.5. It still works in v0.5 but will be removed in future versions.
|
||||
|
||||
|
||||
### React.renderComponentToString
|
||||
|
||||
```javascript
|
||||
string renderComponentToString(ReactComponent component)
|
||||
```
|
||||
|
||||
Render a component to its initial HTML. This should only be used on the server. React will return an HTML string. You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
|
||||
|
||||
If you call `React.renderComponent()` on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.
|
||||
118
docs/docs/ref-02-component-api.md
Normal file
118
docs/docs/ref-02-component-api.md
Normal file
@@ -0,0 +1,118 @@
|
||||
---
|
||||
id: component-api
|
||||
title: Component API
|
||||
layout: docs
|
||||
permalink: component-api.html
|
||||
prev: top-level-api.html
|
||||
next: component-specs.html
|
||||
---
|
||||
|
||||
## ReactComponent
|
||||
|
||||
Component classes created by `createClass()` return instances of `ReactComponent` when called. Most of the time when you're using React you're either creating or consuming these component objects.
|
||||
|
||||
|
||||
### getDOMNode
|
||||
|
||||
```javascript
|
||||
DOMElement getDOMNode()
|
||||
```
|
||||
|
||||
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements.
|
||||
|
||||
|
||||
### setProps
|
||||
|
||||
```javascript
|
||||
setProps(object nextProps)
|
||||
```
|
||||
|
||||
When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `renderComponent()`. Simply call `setProps()` to change its properties and trigger a re-render.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> This method can only be called on a root-level component. That is, it's only available on the component passed directly to `renderComponent()` and none of its children. If you're inclined to use `setProps()` on a child component, instead take advantage of reactive updates and pass the new prop to the child component when it's created in `render()`.
|
||||
|
||||
|
||||
### replaceProps
|
||||
|
||||
```javascript
|
||||
replaceProps(object nextProps)
|
||||
```
|
||||
|
||||
Like `setProps()` but deletes any pre-existing props instead of merging the two objects.
|
||||
|
||||
|
||||
### transferPropsTo
|
||||
|
||||
```javascript
|
||||
ReactComponent transferPropsTo(ReactComponent targetComponent)
|
||||
```
|
||||
|
||||
Transfer properties from this component to a target component that have not already been set on the target component. After the props are updated, `targetComponent` is returned as a convenience. This function is useful when creating simple HTML-like components:
|
||||
|
||||
```javascript
|
||||
var Avatar = React.createClass({
|
||||
render: function() {
|
||||
return this.transferPropsTo(
|
||||
<img src={"/avatars/" + this.props.userId + ".png"} userId={null} />
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// <Avatar userId={17} width={200} height={200} />
|
||||
```
|
||||
|
||||
Properties that are specified directly on the target component instance (such as `src` and `userId` in the above example) will not be overwritten by `transferPropsTo`.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> Use `transferPropsTo` with caution; it encourages tight coupling and makes it easy to accidentally introduce implicit dependencies between components. When in doubt, it's safer to explicitly copy the properties that you need onto the child component.
|
||||
|
||||
|
||||
### setState
|
||||
|
||||
```javascript
|
||||
setState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks. In addition, you can supply an optional callback function that is executed once `setState` is completed.
|
||||
|
||||
> Notes:
|
||||
>
|
||||
> *NEVER* mutate `this.state` directly, as calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable.
|
||||
>
|
||||
> `setState()` does not immediately mutate `this.state` but creates a pending state transition. Accessing `this.state` after calling this method can potentially return the existing value.
|
||||
>
|
||||
> There is no guarantee of synchronous operation of calls to `setState` and calls may be batched for performance gains.
|
||||
|
||||
|
||||
### replaceState
|
||||
|
||||
```javascript
|
||||
replaceState(object nextState[, function callback])
|
||||
```
|
||||
|
||||
Like `setState()` but deletes any pre-existing state keys that are not in nextState.
|
||||
|
||||
|
||||
### forceUpdate()
|
||||
|
||||
```javascript
|
||||
forceUpdate([function callback])
|
||||
```
|
||||
|
||||
If your `render()` method reads from something other than `this.props` or `this.state`, you'll need to tell React when it needs to re-run `render()` by calling `forceUpdate()`. You'll also need to call `forceUpdate()` if you mutate `this.state` directly.
|
||||
|
||||
Calling `forceUpdate()` will cause `render()` to be called on the component and its children, but React will still only update the DOM if the markup changes.
|
||||
|
||||
Normally you should try to avoid all uses of `forceUpdate()` and only read from `this.props` and `this.state` in `render()`. This makes your application much simpler and more efficient.
|
||||
|
||||
|
||||
### isMounted()
|
||||
|
||||
```javascript
|
||||
bool isMounted()
|
||||
```
|
||||
|
||||
`isMounted()` returns true if the component is rendered into the DOM, false otherwise. You can use this method to guard asynchronous calls to `setState()` or `forceUpdate()`.
|
||||
218
docs/docs/ref-03-component-specs.md
Normal file
218
docs/docs/ref-03-component-specs.md
Normal file
@@ -0,0 +1,218 @@
|
||||
---
|
||||
id: component-specs
|
||||
title: Component Specs and Lifecycle
|
||||
layout: docs
|
||||
permalink: component-specs.html
|
||||
prev: component-api.html
|
||||
next: tags-and-attributes.html
|
||||
---
|
||||
|
||||
## Component Specifications
|
||||
|
||||
When creating a component class by invoking `React.createClass()`, you should provide a specification object that contains a `render` method and can optionally contain other lifecycle methods described here.
|
||||
|
||||
|
||||
### render
|
||||
|
||||
```javascript
|
||||
ReactComponent render()
|
||||
```
|
||||
|
||||
The `render()` method is required.
|
||||
|
||||
When called, it should examine `this.props` and `this.state` and return a single child component. This child component can be either a virtual representation of a native DOM component (such as `<div />` or `React.DOM.div()`) or another composite component that you've defined yourself.
|
||||
|
||||
The `render()` function should be *pure*, meaning that it does not modify component state, it returns the same result each time it's invoked, and it does not read from or write to the DOM or otherwise interact with the browser (e.g., by using `setTimeout`). If you need to interact with the browser, perform your work in `componentDidMount()` or the other lifecycle methods instead. Keeping `render()` pure makes server rendering more practical and makes components easier to think about.
|
||||
|
||||
|
||||
### getInitialState
|
||||
|
||||
```javascript
|
||||
object getInitialState()
|
||||
```
|
||||
|
||||
Invoked once before the component is mounted. The return value will be used as the initial value of `this.state`.
|
||||
|
||||
|
||||
### getDefaultProps
|
||||
|
||||
```javascript
|
||||
object getDefaultProps()
|
||||
```
|
||||
|
||||
Invoked once when the component is mounted. Values in the mapping will be set on `this.props` if that prop is not specified by the parent component (i.e. using an `in` check).
|
||||
|
||||
This method is invoked before `getInitialState` and therefore cannot rely on `this.state` or use `this.setState`.
|
||||
|
||||
|
||||
### propTypes
|
||||
|
||||
```javascript
|
||||
object propTypes
|
||||
```
|
||||
|
||||
The `propTypes` object allows you to validate props being passed to your components. For more information about `propTypes`, see [Reusable Components](/react/docs/reusable-components.html).
|
||||
|
||||
<!-- TODO: Document propTypes here directly. -->
|
||||
|
||||
|
||||
### mixins
|
||||
|
||||
```javascript
|
||||
array mixins
|
||||
```
|
||||
|
||||
The `mixins` array allows you to use mixins to share behavior among multiple components. For more information about mixins, see [Reusable Components](/react/docs/reusable-components.html).
|
||||
|
||||
<!-- TODO: Document mixins here directly. -->
|
||||
|
||||
|
||||
### statics
|
||||
|
||||
```javascript
|
||||
object statics
|
||||
```
|
||||
|
||||
The `statics` object allows you to define static methods that can be called on the component class. For example:
|
||||
|
||||
```javascript
|
||||
var MyComponent = React.createClass({
|
||||
statics: {
|
||||
customMethod: function(foo) {
|
||||
return foo === 'bar';
|
||||
}
|
||||
},
|
||||
render: function() {
|
||||
}
|
||||
});
|
||||
|
||||
MyComponent.customMethod('bar'); // true
|
||||
```
|
||||
|
||||
Methods defined within this block are _static_, meaning that you can run them before any component instances are created, and the methods do not have access to the props or state of your components. If you want to check the value of props in a static method, have the caller pass in the props as an argument to the static method.
|
||||
|
||||
|
||||
### displayName
|
||||
|
||||
```javascript
|
||||
string displayName
|
||||
```
|
||||
|
||||
The `displayName` string is used in debugging messages. JSX sets this value automatically, see [JSX in Depth](/react/docs/jsx-in-depth.html#react-composite-components).
|
||||
|
||||
|
||||
## Lifecycle Methods
|
||||
|
||||
Various methods are executed at specific points in a component's lifecycle.
|
||||
|
||||
|
||||
### Mounting: componentWillMount
|
||||
|
||||
```javascript
|
||||
componentWillMount()
|
||||
```
|
||||
|
||||
Invoked once, immediately before the initial rendering occurs. If you call `setState` within this method, `render()` will see the updated state and will be executed only once despite the state change.
|
||||
|
||||
|
||||
### Mounting: componentDidMount
|
||||
|
||||
```javascript
|
||||
componentDidMount()
|
||||
```
|
||||
|
||||
Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via `this.getDOMNode()`.
|
||||
|
||||
If you want to integrate with other JavaScript frameworks, set timers using `setTimeout` or `setInterval`, or send AJAX requests, perform those operations in this method.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> Prior to v0.9, the DOM node was passed in as the last argument. If you were using this, you can still access the DOM node by calling `this.getDOMNode()`.
|
||||
|
||||
|
||||
### Updating: componentWillReceiveProps
|
||||
|
||||
```javascript
|
||||
componentWillReceiveProps(object nextProps)
|
||||
```
|
||||
|
||||
Invoked when a component is receiving new props. This method is not called for the initial render.
|
||||
|
||||
Use this as an opportunity to react to a prop transition before `render()` is called by updating the state using `this.setState()`. The old props can be accessed via `this.props`. Calling `this.setState()` within this function will not trigger an additional render.
|
||||
|
||||
```javascript
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
this.setState({
|
||||
likesIncreasing: nextProps.likeCount > this.props.likeCount
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
> Note:
|
||||
>
|
||||
> There is no analogous method `componentWillReceiveState`. An incoming prop transition may cause a state change, but the opposite is not true. If you need to perform operations in response to a state change, use `componentWillUpdate`.
|
||||
|
||||
|
||||
### Updating: shouldComponentUpdate
|
||||
|
||||
```javascript
|
||||
boolean shouldComponentUpdate(object nextProps, object nextState)
|
||||
```
|
||||
|
||||
Invoked before rendering when new props or state are being received. This method is not called for the initial render or when `forceUpdate` is used.
|
||||
|
||||
Use this as an opportunity to `return false` when you're certain that the
|
||||
transition to the new props and state will not require a component update.
|
||||
|
||||
```javascript
|
||||
shouldComponentUpdate: function(nextProps, nextState) {
|
||||
return !equal(nextProps, this.props) || !equal(nextState, this.state);
|
||||
}
|
||||
```
|
||||
|
||||
If `shouldComponentUpdate` returns false, then `render()` will be completely skipped until the next state change. (In addition, `componentWillUpdate` and `componentDidUpdate` will not be called.)
|
||||
|
||||
By default, `shouldComponentUpdate` always returns true to prevent subtle bugs when `state` is mutated in place, but if you are careful to always treat `state` as immutable and to read only from `props` and `state` in `render()` then you can override `shouldComponentUpdate` with an implementation that compares the old props and state to their replacements.
|
||||
|
||||
If performance is a bottleneck, especially with dozens or hundreds of components, use `shouldComponentUpdate` to speed up your app.
|
||||
|
||||
|
||||
### Updating: componentWillUpdate
|
||||
|
||||
```javascript
|
||||
componentWillUpdate(object nextProps, object nextState)
|
||||
```
|
||||
|
||||
Invoked immediately before rendering when new props or state are being received. This method is not called for the initial render.
|
||||
|
||||
Use this as an opportunity to perform preparation before an update occurs.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> You *cannot* use `this.setState()` in this method. If you need to update state in response to a prop change, use `componentWillReceiveProps` instead.
|
||||
|
||||
|
||||
### Updating: componentDidUpdate
|
||||
|
||||
```javascript
|
||||
componentDidUpdate(object prevProps, object prevState)
|
||||
```
|
||||
|
||||
Invoked immediately after updating occurs. This method is not called for the initial render.
|
||||
|
||||
Use this as an opportunity to operate on the DOM when the component has been updated.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> Prior to v0.9, the DOM node was passed in as the last argument. If you were using this, you can still access the DOM node by calling `this.getDOMNode()`.
|
||||
|
||||
|
||||
### Unmounting: componentWillUnmount
|
||||
|
||||
```javascript
|
||||
componentWillUnmount()
|
||||
```
|
||||
|
||||
Invoked immediately before a component is unmounted from the DOM.
|
||||
|
||||
Perform any necessary cleanup in this method, such as invalidating timers or cleaning up any DOM elements that were created in `componentDidMount`.
|
||||
77
docs/docs/ref-04-tags-and-attributes.md
Normal file
77
docs/docs/ref-04-tags-and-attributes.md
Normal file
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: tags-and-attributes
|
||||
title: Tags and Attributes
|
||||
layout: docs
|
||||
permalink: tags-and-attributes.html
|
||||
prev: component-specs.html
|
||||
next: events.html
|
||||
---
|
||||
|
||||
## Supported Tags
|
||||
|
||||
React attempts to support all common elements. If you need an element that isn't listed here, please file an issue.
|
||||
|
||||
### HTML Elements
|
||||
|
||||
The following HTML elements are supported:
|
||||
|
||||
```
|
||||
a abbr address area article aside audio b base bdi bdo big blockquote body br
|
||||
button canvas caption cite code col colgroup data datalist dd del details dfn
|
||||
div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6
|
||||
head header hr html i iframe img input ins kbd keygen label legend li link
|
||||
main map mark menu menuitem meta meter nav noscript object ol optgroup option
|
||||
output p param pre progress q rp rt ruby s samp script section select small
|
||||
source span strong style sub summary sup table tbody td textarea tfoot th
|
||||
thead time title tr track u ul var video wbr
|
||||
```
|
||||
|
||||
### SVG elements
|
||||
|
||||
The following SVG elements are supported:
|
||||
|
||||
```
|
||||
circle defs g line linearGradient path polygon polyline radialGradient rect
|
||||
stop svg text
|
||||
```
|
||||
|
||||
You may also be interested in [react-art](https://github.com/facebook/react-art), a drawing library for React that can render to Canvas, SVG, or VML (for IE8).
|
||||
|
||||
|
||||
## Supported Attributes
|
||||
|
||||
React supports all `data-*` and `aria-*` attributes as well as every attribute in the following lists.
|
||||
|
||||
> Note:
|
||||
>
|
||||
> All attributes are camel-cased and the attributes `class` and `for` are `className` and `htmlFor`, respectively, to match the DOM API specification.
|
||||
|
||||
For a list of events, see [Supported Events](/react/docs/events.html).
|
||||
|
||||
### HTML Attributes
|
||||
|
||||
These standard attributes are supported:
|
||||
|
||||
```
|
||||
accept accessKey action allowFullScreen allowTransparency alt async
|
||||
autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked
|
||||
className colSpan cols content contentEditable contextMenu controls data
|
||||
dateTime defer dir disabled draggable encType form formNoValidate frameBorder
|
||||
height hidden href htmlFor httpEquiv icon id label lang list loop max
|
||||
maxLength method min multiple name noValidate pattern placeholder poster
|
||||
preload radioGroup readOnly rel required role rowSpan rows sandbox scope
|
||||
scrollLeft scrollTop seamless selected size span spellCheck src srcDoc step
|
||||
style tabIndex target title type value width wmode
|
||||
```
|
||||
|
||||
In addition, the non-standard `autoCapitalize` and `autoCorrect` attributes are supported for Mobile Safari, and the `property` attribute is supported for Open Graph `<meta>` tags.
|
||||
|
||||
There is also the React-specific attribute `dangerouslySetInnerHTML` ([more here](/react/docs/special-non-dom-attributes.html)), used for directly inserting HTML strings into a component.
|
||||
|
||||
### SVG Attributes
|
||||
|
||||
```
|
||||
cx cy d fill fx fy gradientTransform gradientUnits offset points r rx ry
|
||||
spreadMethod stopColor stopOpacity stroke strokeLinecap strokeWidth transform
|
||||
version viewBox x1 x2 x y1 y2 y
|
||||
```
|
||||
188
docs/docs/ref-05-events.md
Normal file
188
docs/docs/ref-05-events.md
Normal file
@@ -0,0 +1,188 @@
|
||||
---
|
||||
id: events
|
||||
title: Event System
|
||||
layout: docs
|
||||
permalink: events.html
|
||||
prev: tags-and-attributes.html
|
||||
next: dom-differences.html
|
||||
---
|
||||
|
||||
## SyntheticEvent
|
||||
|
||||
Your event handlers will be passed instances of `SyntheticEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers.
|
||||
|
||||
If you find that you need the underlying browser event for some reason, simply use the `nativeEvent` attribute to get it. Every `SyntheticEvent` object has the following attributes:
|
||||
|
||||
```javascript
|
||||
boolean bubbles
|
||||
boolean cancelable
|
||||
DOMEventTarget currentTarget
|
||||
boolean defaultPrevented
|
||||
Number eventPhase
|
||||
boolean isTrusted
|
||||
DOMEvent nativeEvent
|
||||
void preventDefault()
|
||||
void stopPropagation()
|
||||
DOMEventTarget target
|
||||
Date timeStamp
|
||||
String type
|
||||
```
|
||||
|
||||
|
||||
## Supported Events
|
||||
|
||||
React normalizes events so that they have consistent properties across
|
||||
different browsers.
|
||||
|
||||
|
||||
### Clipboard Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onCopy onCut onPaste
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
DOMDataTransfer clipboardData
|
||||
```
|
||||
|
||||
|
||||
### Keyboard Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onKeyDown onKeyPress onKeyUp
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
boolean altKey
|
||||
boolean ctrlKey
|
||||
Number charCode
|
||||
String key
|
||||
Number keyCode
|
||||
String locale
|
||||
Number location
|
||||
boolean metaKey
|
||||
boolean repeat
|
||||
boolean shiftKey
|
||||
Number which
|
||||
```
|
||||
|
||||
|
||||
### Focus Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onFocus onBlur
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
DOMEventTarget relatedTarget
|
||||
```
|
||||
|
||||
|
||||
### Form Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onChange onInput onSubmit
|
||||
```
|
||||
|
||||
For more information about the onChange event, see [Forms](/react/docs/forms.html).
|
||||
|
||||
|
||||
### Mouse Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onClick onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave
|
||||
onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
|
||||
onMouseMove onMouseOut onMouseOver onMouseUp
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
boolean altKey
|
||||
Number button
|
||||
Number buttons
|
||||
Number clientX
|
||||
Number clientY
|
||||
boolean ctrlKey
|
||||
boolean metaKey
|
||||
Number pageX
|
||||
Number pageY
|
||||
DOMEventTarget relatedTarget
|
||||
Number screenX
|
||||
Number screenY
|
||||
boolean shiftKey
|
||||
```
|
||||
|
||||
|
||||
### Touch events
|
||||
|
||||
To enable touch events, call `React.initializeTouchEvents(true)` before
|
||||
rendering any component.
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onTouchCancel onTouchEnd onTouchMove onTouchStart
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
boolean altKey
|
||||
DOMTouchList changedTouches
|
||||
boolean ctrlKey
|
||||
boolean metaKey
|
||||
boolean shiftKey
|
||||
DOMTouchList targetTouches
|
||||
DOMTouchList touches
|
||||
```
|
||||
|
||||
|
||||
### UI Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onScroll
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
Number detail
|
||||
DOMAbstractView view
|
||||
```
|
||||
|
||||
|
||||
### Wheel Events
|
||||
|
||||
Event names:
|
||||
|
||||
```
|
||||
onWheel
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
```javascript
|
||||
Number deltaX
|
||||
Number deltaMode
|
||||
Number deltaY
|
||||
Number deltaZ
|
||||
```
|
||||
16
docs/docs/ref-06-dom-differences.md
Normal file
16
docs/docs/ref-06-dom-differences.md
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
id: dom-differences
|
||||
title: DOM Differences
|
||||
layout: docs
|
||||
permalink: dom-differences.html
|
||||
prev: events.html
|
||||
next: special-non-dom-attributes.html
|
||||
---
|
||||
|
||||
React has implemented a browser-independent events and DOM system for performance and cross-browser compatibility reasons. We took the opportunity to clean up a few rough edges in browser DOM implementations.
|
||||
|
||||
* All DOM properties and attributes (including event handlers) should be camelCased to be consistent with standard JavaScript style. We intentionally break with the spec here since the spec is inconsistent. **However**, `data-*` and `aria-*` attributes [conform to the specs](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#data-*) and should be lower-cased only.
|
||||
* The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM `style` JavaScript property, is more efficient, and prevents XSS security holes.
|
||||
* All event objects conform to the W3C spec, and all events (including submit) bubble correctly per the W3C spec. See [Event System](/react/docs/events.html) for more details.
|
||||
* The `onChange` event behaves as you would expect it to: whenever a form field is changed this event is fired rather than inconsistently on blur. We intentionally break from existing browser behavior because `onChange` is a misnomer for its behavior and React relies on this event to react to user input in real time. See [Forms](/react/docs/forms.html) for more details.
|
||||
* Form input attributes such as `value` and `checked`, as well as `textarea`. [More here](/react/docs/forms.html).
|
||||
14
docs/docs/ref-07-special-non-dom-attributes.md
Normal file
14
docs/docs/ref-07-special-non-dom-attributes.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
id: special-non-dom-attributes
|
||||
title: Special Non-DOM Attributes
|
||||
layout: docs
|
||||
permalink: special-non-dom-attributes.html
|
||||
prev: dom-differences.html
|
||||
next: reconciliation.html
|
||||
---
|
||||
|
||||
Beside [DOM differences](/react/docs/dom-differences.html), React offers some attributes that simply don't exist in DOM.
|
||||
|
||||
- `key`: an optional, unique identifier. When your component shuffles around during `render` passes, it might be destroyed and recreated due to the diff algorithm. Assigning it a key that persists makes sure the component stays. See more [here](/react/docs/multiple-components.html#dynamic-children).
|
||||
- `ref`: see [here](/react/docs/more-about-refs.html).
|
||||
- `dangerouslySetInnerHTML`: takes an object with the key `__html` and a DOM string as value. This is mainly for cooperating with DOM string manipulation libraries. Refer to the last example on the front page.
|
||||
133
docs/docs/ref-08-reconciliation.md
Normal file
133
docs/docs/ref-08-reconciliation.md
Normal file
@@ -0,0 +1,133 @@
|
||||
---
|
||||
id: reconciliation
|
||||
title: Reconciliation
|
||||
layout: docs
|
||||
permalink: reconciliation.html
|
||||
prev: special-non-dom-attributes.html
|
||||
---
|
||||
|
||||
React key design decision is to make the API seem like it re-renders the whole app on every update. This makes writing applications a lot easier but is also an incredible challenge to make it tractable. This article explains how with powerful heuristics we managed to turn a O(n<sup>3</sup>) problem into a O(n) one.
|
||||
|
||||
|
||||
## Motivation
|
||||
|
||||
Generating the minimum number of operations to transform one tree into another is a complex and well-studied problem. The [state of the art algorithms](http://grfia.dlsi.ua.es/ml/algorithms/references/editsurvey_bille.pdf) have a complexity in the order of O(n<sup>3</sup>) where n is the number of nodes in the tree.
|
||||
|
||||
This means that displaying 1000 nodes would require in the order of one billion comparisons. This is far too expensive for our use case. To put this number in perspective, CPUs nowadays execute roughly 3 billion instruction per second. So even with the most performant implementation, we wouldn't be able to compute that diff in less than a second.
|
||||
|
||||
Since an optimal algorithm is not tractable, we implement a non-optimal O(n) algorithm using heuristics based on two assumptions:
|
||||
|
||||
1. Two components of the same class will generate similar trees and two components of different classes will generate different trees.
|
||||
2. It is possible to provide a unique key for elements that is stable across different renders.
|
||||
|
||||
In practice, these assumptions are ridiculously fast for almost all practical use cases.
|
||||
|
||||
|
||||
## Pair-wise diff
|
||||
|
||||
In order to do a tree diff, we first need to be able to diff two nodes. There are three different cases being handled.
|
||||
|
||||
|
||||
### Different Node Types
|
||||
|
||||
If the node type is different, React is going to treat them as two different sub-trees, throw away the first one and build/insert the second one.
|
||||
|
||||
```xml
|
||||
renderA: <div />
|
||||
renderB: <span />
|
||||
=> [removeNode <div />], [insertNode <span />]
|
||||
```
|
||||
|
||||
The same logic is used for custom components. If they are not of the same type, React is not going to even try at matching what they render. It is just going to remove the first one from the DOM and insert the second one.
|
||||
|
||||
```xml
|
||||
renderA: <Header />
|
||||
renderB: <Content />
|
||||
=> [removeNode <Header />], [insertNode <Content />]
|
||||
```
|
||||
|
||||
Having this high level knowledge is a very important aspect of why React diff algorithm is both fast and precise. It provides a good heuristic to quickly prune big parts of the tree and focus on parts likely to be similar.
|
||||
|
||||
It is very unlikely that a `<Header>` element is going generate a DOM that is going to look like what a `<Content>` would generate. Instead of spending time trying to match those two structures, React just re-builds the tree from scratch.
|
||||
|
||||
As a corollary, if there is a `<Header>` element at the same position in two consecutive renders, you would expect to see a very similar structure and it is worth exploring it.
|
||||
|
||||
|
||||
### DOM Nodes
|
||||
|
||||
When comparing two DOM nodes, we look at the attributes of both and can decide which of them changed in linear time.
|
||||
|
||||
```xml
|
||||
renderA: <div id="before" />
|
||||
renderB: <div id="after" />
|
||||
=> [replaceAttribute id "after"]
|
||||
```
|
||||
|
||||
Instead of treating style as an opaque string, a key-value object is used instead. This lets us update only the properties that changed.
|
||||
|
||||
```xml
|
||||
renderA: <div style={{'{{'}}color: 'red'}} />
|
||||
renderB: <div style={{'{{'}}fontWeight: 'bold'}} />
|
||||
=> [removeStyle color], [addStyle font-weight 'bold']
|
||||
```
|
||||
|
||||
After the attributes have been updated, we recurse on all the children.
|
||||
|
||||
|
||||
### Custom Components
|
||||
|
||||
We decided that the two custom components are the same. Since components are stateful, we cannot just use the new component and call it a day. React takes all the attributes from the new component and call `component[Will/Did]ReceiveProps()` on the previous one.
|
||||
|
||||
The previous component is now operational. Its `render()` method is called and the diff algorithm restarts with the new result and the previous result.
|
||||
|
||||
|
||||
## List-wise diff
|
||||
|
||||
### Problematic Case
|
||||
|
||||
In order to do children reconciliation, React adopts a very naive approach. It goes over the list of children both at the same time and whenever there's a difference generates a mutation.
|
||||
|
||||
For example if you add an element at the end:
|
||||
|
||||
```xml
|
||||
renderA: <div><span>first</span></div>
|
||||
renderB: <div><span>first</span><span>second</span></div>
|
||||
=> [insertNode <span>second</span>]
|
||||
```
|
||||
|
||||
Inserting an element at the beginning is problematic. React is going to see that both nodes are spans and therefore run into a mutation mode.
|
||||
|
||||
```xml
|
||||
renderA: <div><span>first</span></div>
|
||||
renderB: <div><span>second</span><span>first</span></div>
|
||||
=> [replaceAttribute textContent 'second'], [insertNode <span>first</span>]
|
||||
```
|
||||
|
||||
There are many algorithms that attempt to find the minimum sets of operations to transform a list of elements. [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance) can find the minimum using single element insertion, deletion and substitution in O(n<sup>2</sup>). Even if we were to use Levenshtein, this doesn't find when a node has moved into another position and algorithms to do that have much worse complexity.
|
||||
|
||||
### Keys
|
||||
|
||||
In order to solve this seemingly intractable issue, an optional attribute has been introduced. You can provide for each child a key that is going to be used to do the matching. If you specify a key, React is now able to find insertion, deletion, substitution and moves in O(n) using a hash table.
|
||||
|
||||
|
||||
```xml
|
||||
renderA: <div><span key="first">first</span></div>
|
||||
renderB: <div><span key="second">second</span><span key="first">first</span></div>
|
||||
=> [insertNode <span>second</span>]
|
||||
```
|
||||
|
||||
In practice, finding a key is not really hard. Most of the time, the element you are going to display already have a unique id. When it is not the case, you can hash some parts of the content to generate an id. Remember that the id only has to be unique among its sibling, not globally unique.
|
||||
|
||||
|
||||
## Trade-offs
|
||||
|
||||
It is important to remember that the reconciliation algorithm is an implementation detail. React could re-render the whole app on every action, the end-result would be the same. We are regularly refining the heuristics in order to make common use cases faster.
|
||||
|
||||
In the current implementation, you can express the fact that a sub-tree has been moved between siblings, but you cannot tell that it has moved somewhere else. The algorithm will re-render that full sub-tree.
|
||||
|
||||
Because we rely on two heuristics, if the assumptions behind them are not met, performance will suffer.
|
||||
|
||||
1. The algorithm will not try to match sub-trees of different components classes. If you see yourself alternating between two components classes with very similar output, you may want to make it the same class. In practice, we haven't found this to be an issue.
|
||||
|
||||
2. If you don't provide stable keys (by using Math.random() for example), all the sub-trees are going to be re-rendered every single time. By giving the users the choice to chose the key, they have the ability to shoot themselves in the foot.
|
||||
|
||||
4
docs/docs/reference.html
Normal file
4
docs/docs/reference.html
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
layout: redirect
|
||||
destination: top-level-api.html
|
||||
---
|
||||
147
docs/docs/thinking-in-react.md
Normal file
147
docs/docs/thinking-in-react.md
Normal file
@@ -0,0 +1,147 @@
|
||||
---
|
||||
id: thinking-in-react
|
||||
title: Thinking in React
|
||||
layout: docs
|
||||
prev: tutorial.html
|
||||
next: videos.html
|
||||
---
|
||||
|
||||
This was originally a [blog post](/react/blog/2013/11/05/thinking-in-react.html) from the [official React blog](/react/blog).
|
||||
|
||||
React is, in my opinion, the premier way to build big, fast Web apps with JavaScript. It's scaled very well for us at Facebook and Instagram.
|
||||
|
||||
One of the many great parts of React is how it makes you think about apps as you build them. In this post I'll walk you through the thought process of building a searchable product data table using React.
|
||||
|
||||
## Start with a mock
|
||||
|
||||
Imagine that we already have a JSON API and a mock from our designer. Our designer apparently isn't very good because the mock looks like this:
|
||||
|
||||

|
||||
|
||||
Our JSON API returns some data that looks like this:
|
||||
|
||||
```
|
||||
[
|
||||
{category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"},
|
||||
{category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"},
|
||||
{category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"},
|
||||
{category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"},
|
||||
{category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"},
|
||||
{category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"}
|
||||
];
|
||||
```
|
||||
|
||||
## Step 1: break the UI into a component hierarchy
|
||||
|
||||
The first thing you'll want to do is to draw boxes around every component (and subcomponent) in the mock and give them all names. If you're working with a designer they may have already done this, so go talk to them! Their Photoshop layer names may end up being the names of your React components!
|
||||
|
||||
But how do you know what should be its own component? Just use the same techniques for deciding if you should create a new function or object. One such technique is the [single responsibility principle](http://en.wikipedia.org/wiki/Single_responsibility_principle), that is, a component should ideally only do one thing. If it ends up growing it should be decomposed into smaller subcomponents.
|
||||
|
||||
Since you're often displaying a JSON data model to a user, you'll find that if your model was built correctly your UI (and therefore your component structure) will map nicely onto it. That's because user interfaces and data models tend to adhere to the same *information architecture* which means the work of separating your UI into components is often trivial. Just break it up into components that represent exactly one piece of your data model.
|
||||
|
||||

|
||||
|
||||
You'll see here that we have five components in our simple app. I've italicized the data each component represents.
|
||||
|
||||
1. **`FilterableProductTable` (orange):** contains the entirety of the example
|
||||
2. **`SearchBar` (blue):** receives all *user input*
|
||||
3. **`ProductTable` (green):** displays and filters the *data collection* based on *user input*
|
||||
4. **`ProductCategoryRow` (turquoise):** displays a heading for each *category*
|
||||
5. **`ProductRow` (red):** displays a row for each *product*
|
||||
|
||||
If you look at `ProductTable` you'll see that the table header (containing the "Name" and "Price" labels) isn't its own component. This is a matter of preference and there's an argument to be made either way. For this example I left it as part of `ProductTable` because it is part of rendering the *data collection* which is `ProductTable`'s responsibility. However if this header grows to be complex (i.e. if we were to add affordances for sorting) it would certainly make sense to make this its own `ProductTableHeader` component.
|
||||
|
||||
Now that we've identified the components in our mock, let's arrange them into a hierarchy. This is easy. Components that appear within another component in the mock should appear as a child in the hierarchy:
|
||||
|
||||
* `FilterableProductTable`
|
||||
* `SearchBar`
|
||||
* `ProductTable`
|
||||
* `ProductCategoryRow`
|
||||
* `ProductRow`
|
||||
|
||||
## Step 2: Build a static version in React
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/6wQMG/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
Now that you have your component hierarchy it's time to start implementing your app. The easiest way is to build a version that takes your data model and renders the UI but has no interactivity. It's easiest to decouple these processes because building a static version requires a lot of typing and no thinking, and adding interactivity requires a lot of thinking and not a lot of typing. We'll see why.
|
||||
|
||||
To build a static version of your app that renders your data model you'll want to build components that reuse other components and pass data using *props*. *props* are a way of passing data from parent to child. If you're familiar with the concept of *state*, **don't use state at all** to build this static version. State is reserved only for interactivity, that is, data that changes over time. Since this is a static version of the app you don't need it.
|
||||
|
||||
You can build top-down or bottom-up. That is, you can either start with building the components higher up in the hierarchy (i.e. starting with `FilterableProductTable`) or with the ones lower in it (`ProductRow`). In simpler examples it's usually easier to go top-down and on larger projects it's easier to go bottom-up and write tests as you build.
|
||||
|
||||
At the end of this step you'll have a library of reusable components that render your data model. The components will only have `render()` methods since this is a static version of your app. The component at the top of the hierarchy (`FilterableProductTable`) will take your data model as a prop. If you make a change to your underlying data model and call `renderComponent()` again the UI will be updated. It's easy to see how your UI is updated and where to make changes since there's nothing complicated going on since React's **one-way data flow** (also called *one-way binding*) keeps everything modular, easy to reason about, and fast.
|
||||
|
||||
Simply refer to the [React docs](http://facebook.github.io/react/docs/) if you need help executing this step.
|
||||
|
||||
### A brief interlude: props vs state
|
||||
|
||||
There are two types of "model" data in React: props and state. It's important to understand the distinction between the two; skim [the official React docs](http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html) if you aren't sure what the difference is.
|
||||
|
||||
## Step 3: Identify the minimal (but complete) representation of UI state
|
||||
|
||||
To make your UI interactive you need to be able to trigger changes to your underlying data model. React makes this easy with **state**.
|
||||
|
||||
To build your app correctly you first need to think of the minimal set of mutable state that your app needs. The key here is DRY: *Don't Repeat Yourself*. Figure out what the absolute minimal representation of the state of your application needs to be and compute everything else you need on-demand. For example, if you're building a TODO list, just keep an array of the TODO items around; don't keep a separate state variable for the count. Instead, when you want to render the TODO count simply take the length of the TODO items array.
|
||||
|
||||
Think of all of the pieces of data in our example application. We have:
|
||||
|
||||
* The original list of products
|
||||
* The search text the user has entered
|
||||
* The value of the checkbox
|
||||
* The filtered list of products
|
||||
|
||||
Let's go through each one and figure out which one is state. Simply ask three questions about each piece of data:
|
||||
|
||||
1. Is it passed in from a parent via props? If so, it probably isn't state.
|
||||
2. Does it change over time? If not, it probably isn't state.
|
||||
3. Can you compute it based on any other state or props in your component? If so, it's not state.
|
||||
|
||||
The original list of products is passed in as props, so that's not state. The search text and the checkbox seem to be state since they change over time and can't be computed from anything. And finally, the filtered list of products isn't state because it can be computed by combining the original list of products with the search text and value of the checkbox.
|
||||
|
||||
So finally, our state is:
|
||||
|
||||
* The search text the user has entered
|
||||
* The value of the checkbox
|
||||
|
||||
## Step 4: Identify where your state should live
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/QvHnx/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
OK, so we've identified what the minimal set of app state is. Next we need to identify which component mutates, or *owns*, this state.
|
||||
|
||||
Remember: React is all about one-way data flow down the component hierarchy. It may not be immediately clear which component should own what state. **This is often the most challenging part for newcomers to understand,** so follow these steps to figure it out:
|
||||
|
||||
For each piece of state in your application:
|
||||
|
||||
* Identify every component that renders something based on that state.
|
||||
* Find a common owner component (a single component above all the components that need the state in the hierarchy).
|
||||
* Either the common owner or another component higher up in the hierarchy should own the state.
|
||||
* If you can't find a component where it makes sense to own the state, create a new component simply for holding the state and add it somewhere in the hierarchy above the common owner component.
|
||||
|
||||
Let's run through this strategy for our application:
|
||||
|
||||
* `ProductTable` needs to filter the product list based on state and `SearchBar` needs to display the search text and checked state.
|
||||
* The common owner component is `FilterableProductTable`.
|
||||
* It conceptually makes sense for the filter text and checked value to live in `FilterableProductTable`
|
||||
|
||||
Cool, so we've decided that our state lives in `FilterableProductTable`. First, add a `getInitialState()` method to `FilterableProductTable` that returns `{filterText: '', inStockOnly: false}` to reflect the initial state of your application. Then pass `filterText` and `inStockOnly` to `ProductTable` and `SearchBar` as a prop. Finally, use these props to filter the rows in `ProductTable` and set the values of the form fields in `SearchBar`.
|
||||
|
||||
You can start seeing how your application will behave: set `filterText` to `"ball"` and refresh your app. You'll see the data table is updated correctly.
|
||||
|
||||
## Step 5: Add inverse data flow
|
||||
|
||||
<iframe width="100%" height="300" src="http://jsfiddle.net/3Vs3Q/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
|
||||
|
||||
So far we've built an app that renders correctly as a function of props and state flowing down the hierarchy. Now it's time to support data flowing the other way: the form components deep in the hierarchy need to update the state in `FilterableProductTable`.
|
||||
|
||||
React makes this data flow explicit to make it easy to understand how your program works, but it does require a little more typing than traditional two-way data binding. React provides an add-on called `ReactLink` to make this pattern as convenient as two-way binding, but for the purpose of this post we'll keep everything explicit.
|
||||
|
||||
If you try to type or check the box in the current version of the example you'll see that React ignores your input. This is intentional, as we've set the `value` prop of the `input` to always be equal to the `state` passed in from `FilterableProductTable`.
|
||||
|
||||
Let's think about what we want to happen. We want to make sure that whenever the user changes the form we update the state to reflect the user input. Since components should only update their own state, `FilterableProductTable` will pass a callback to `SearchBar` that will fire whenever the state should be updated. We can use the `onChange` event on the inputs to be notified of it. And the callback passed by `FilterableProductTable` will call `setState()` and the app will be updated.
|
||||
|
||||
Though this sounds like a lot it's really just a few lines of code. And it's really explicit how your data is flowing throughout the app.
|
||||
|
||||
## And that's it
|
||||
|
||||
Hopefully this gives you an idea of how to think about building components and applications with React. While it may be a little more typing than you're used to, remember that code is read far more than it's written, and it's extremely easy to read this modular, explicit code. As you start to build large libraries of components you'll appreciate this explicitness and modularity, and with code reuse your lines of code will start to shrink :)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user