Compare commits
1256 Commits
0.8-stable
...
0.10-stabl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5b409002b | ||
|
|
9d4baa12a6 | ||
|
|
0606de0db7 | ||
|
|
13817753c6 | ||
|
|
3f37e8e4ab | ||
|
|
fe1b554d9d | ||
|
|
0ecf9f0599 | ||
|
|
acba66fe2e | ||
|
|
661bafb059 | ||
|
|
8f0c1ce7b1 | ||
|
|
3ca2ab8960 | ||
|
|
06844c27a8 | ||
|
|
b2ea0d0e29 | ||
|
|
90682ad1ee | ||
|
|
617de48e53 | ||
|
|
fd4143a198 | ||
|
|
224b6e5a6a | ||
|
|
11707179da | ||
|
|
bfecabf71a | ||
|
|
bcaebecce2 | ||
|
|
6055468d1c | ||
|
|
7ea026e19a | ||
|
|
f7e4667457 | ||
|
|
e88c0b1b1f | ||
|
|
950ecd84ff | ||
|
|
66b027233c | ||
|
|
c28cd1ae1a | ||
|
|
321643a858 | ||
|
|
c29f1823a1 | ||
|
|
424ebb5436 | ||
|
|
94c6396853 | ||
|
|
f832b9ce59 | ||
|
|
d6c5058193 | ||
|
|
59c495511a | ||
|
|
ba717cfc62 | ||
|
|
9af5b6b1c3 | ||
|
|
35321a8908 | ||
|
|
d90046a104 | ||
|
|
d28467796c | ||
|
|
cff284f291 | ||
|
|
7818b9f81f | ||
|
|
76b2e87173 | ||
|
|
a8aa901e1b | ||
|
|
f45ab7c7f4 | ||
|
|
383e385d51 | ||
|
|
bb3916448e | ||
|
|
5936173626 | ||
|
|
1400085fe3 | ||
|
|
6d2dd794ee | ||
|
|
0247d9d625 | ||
|
|
d160715b19 | ||
|
|
5f6d46f696 | ||
|
|
e197768058 | ||
|
|
f893442591 | ||
|
|
c14a26e573 | ||
|
|
6210dd3325 | ||
|
|
1acdd51af3 | ||
|
|
bf6fe2c194 | ||
|
|
e65085846f | ||
|
|
dedf0c20da | ||
|
|
12bdb8d24c | ||
|
|
3b2d176f59 | ||
|
|
68da0eccbe | ||
|
|
593889b87a | ||
|
|
732f4717a6 | ||
|
|
7807413256 | ||
|
|
ec893833ee | ||
|
|
5aaf4dbae9 | ||
|
|
ecea2918cf | ||
|
|
7f24943e5a | ||
|
|
0491d30e7c | ||
|
|
55b0222596 | ||
|
|
b95fbbe4a2 | ||
|
|
e505e47e01 | ||
|
|
e0c487649d | ||
|
|
22057ef61c | ||
|
|
0278f01d95 | ||
|
|
0cec4af8d7 | ||
|
|
8d495f3b6e | ||
|
|
7987e6a51d | ||
|
|
d88d479685 | ||
|
|
3f3187c14f | ||
|
|
c1443e92e6 | ||
|
|
52e8f3fdb0 | ||
|
|
cdf4f07a15 | ||
|
|
6ff116e34b | ||
|
|
d889a01caf | ||
|
|
04f9887f0e | ||
|
|
9b427a322f | ||
|
|
7bbdcdba96 | ||
|
|
5106b793f7 | ||
|
|
83e4ef16e6 | ||
|
|
308c9a0752 | ||
|
|
6a01752f3d | ||
|
|
6fd53815cd | ||
|
|
3efa02da91 | ||
|
|
d9af091244 | ||
|
|
25773ed1b3 | ||
|
|
9e224e615f | ||
|
|
3ce2cd04e2 | ||
|
|
652f5aea28 | ||
|
|
280ff2e5a7 | ||
|
|
5ede7fb619 | ||
|
|
3ea3274ca4 | ||
|
|
2ca810fbf3 | ||
|
|
d9dd9d5cb3 | ||
|
|
9ffd70c688 | ||
|
|
3171436d97 | ||
|
|
9ce7ecc3d9 | ||
|
|
9f9c8bcebf | ||
|
|
ec54dcbd8f | ||
|
|
9766ed5797 | ||
|
|
1d209248ef | ||
|
|
21e06196cd | ||
|
|
4b56947560 | ||
|
|
554b677e60 | ||
|
|
aa70419f9d | ||
|
|
af1b63456e | ||
|
|
ac3051530a | ||
|
|
c5f56f318a | ||
|
|
be2c185888 | ||
|
|
7d0e6c6c0b | ||
|
|
13aa8d37e6 | ||
|
|
06f762da77 | ||
|
|
4ad320dd13 | ||
|
|
521201f121 | ||
|
|
41d30bb7de | ||
|
|
9c87aef67f | ||
|
|
ec8b0d7fbf | ||
|
|
e954a1c0d9 | ||
|
|
1d27770b40 | ||
|
|
4c4446d283 | ||
|
|
a8fc3b940d | ||
|
|
6666538316 | ||
|
|
620c1bc2ff | ||
|
|
99dab49f92 | ||
|
|
9b0534eb77 | ||
|
|
eee04b19e1 | ||
|
|
f734083a17 | ||
|
|
3fe9f9f336 | ||
|
|
e39c19423a | ||
|
|
6203e53d16 | ||
|
|
88a4a566ae | ||
|
|
2f6656e3e9 | ||
|
|
a0ecf47242 | ||
|
|
4b670a08fa | ||
|
|
6b78cfb0f4 | ||
|
|
8df5e55efd | ||
|
|
237adacc3a | ||
|
|
90e996324a | ||
|
|
b2649dd73b | ||
|
|
0217461d16 | ||
|
|
3c4f45fe45 | ||
|
|
6485e21956 | ||
|
|
ae72e6ef91 | ||
|
|
42444f6bb9 | ||
|
|
071d2a947c | ||
|
|
298a05517e | ||
|
|
cbfbb54c1d | ||
|
|
26179d2b79 | ||
|
|
ba78edbed8 | ||
|
|
34b6707132 | ||
|
|
7b773a6b3d | ||
|
|
1dfc5c79f9 | ||
|
|
04111d5228 | ||
|
|
a6c1b91c7d | ||
|
|
f34f0d2912 | ||
|
|
46cae63d2c | ||
|
|
5049fc6b05 | ||
|
|
8b1279e6b2 | ||
|
|
854d1f7c1b | ||
|
|
ab2d59f8b0 | ||
|
|
25cafec4a9 | ||
|
|
61c287c5ea | ||
|
|
7bba8c3257 | ||
|
|
2f0507f730 | ||
|
|
989f6f987d | ||
|
|
e2b006f9ae | ||
|
|
141ff66986 | ||
|
|
da0b34e945 | ||
|
|
cbce621570 | ||
|
|
472be09ff6 | ||
|
|
7144a9f241 | ||
|
|
8aaf5fdbf4 | ||
|
|
445611f3e6 | ||
|
|
b79a3cbd21 | ||
|
|
0790040aac | ||
|
|
2900997b5f | ||
|
|
7eb33ef176 | ||
|
|
5545887a48 | ||
|
|
e29584b49b | ||
|
|
c43b3f406c | ||
|
|
a4d6796705 | ||
|
|
89d4d352e1 | ||
|
|
f3c1383af9 | ||
|
|
c32e398a5c | ||
|
|
95edc396df | ||
|
|
26cd595a98 | ||
|
|
8840ee32f1 | ||
|
|
bb729a5784 | ||
|
|
b99705f690 | ||
|
|
7e7aa21e24 | ||
|
|
1de77f1fbe | ||
|
|
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 |
@@ -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
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -16,4 +16,6 @@ docs/css/react.css
|
||||
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,
|
||||
|
||||
26
.mailmap
26
.mailmap
@@ -1,21 +1,45 @@
|
||||
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>
|
||||
Evan Coonrod <evan@paloalto.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>
|
||||
Jaime Mingo <j.mingov@3boll.com>
|
||||
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 <jeffmo@fb.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>
|
||||
Kunal Mehta <k.mehta@berkeley.edu> <kunalm@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>
|
||||
|
||||
56
.travis.yml
56
.travis.yml
@@ -2,14 +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 "react-with-addons=@build/react-with-addons.js" -F "react-with-addons.min=@build/react-with-addons.min.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
|
||||
|
||||
65
AUTHORS
65
AUTHORS
@@ -1,66 +1,121 @@
|
||||
Adam Solove <asolove@gmail.com>
|
||||
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 <cpojer@fb.com>
|
||||
Christoph Pojer <christoph.pojer@gmail.com>
|
||||
Clay Allsopp <clay.allsopp@gmail.com>
|
||||
Connor McSheffrey <connor.mcsheffrey@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>
|
||||
Daryl Lau <daryl@weak.io>
|
||||
David Hellsing <david@aino.se>
|
||||
David Hu <davidhu91@gmail.com>
|
||||
Dustin Getz <dgetz@wingspan.com>
|
||||
Eric Clemmons <eric@smarterspam.com>
|
||||
Eric Florenzano <floguy@gmail.com>
|
||||
Eric Schoffstall <contra@wearefractal.com>
|
||||
Evan Coonrod <evan@paloalto.com>
|
||||
Fabio M. Costa <fabiomcosta@gmail.com>
|
||||
Felipe Oliveira Carvalho <felipekde@gmail.com>
|
||||
Felix Kling <fkling@fb.com>
|
||||
Fernando Correia <fernando@servicero.com>
|
||||
Greg Hurrell <glh@fb.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>
|
||||
Jaime Mingo <j.mingov@3boll.com>
|
||||
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 Barczewski <jeff.barczewski@gmail.com>
|
||||
Jeff Carpenter <gcarpenterv@gmail.com>
|
||||
Jeff Morrison <jeff@anafx.com>
|
||||
Jeffrey Lin <lin.jeffrey@gmail.com>
|
||||
Jignesh Kakadiya <jigneshhk1992@gmail.com>
|
||||
Jing Chen <jingc@fb.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>
|
||||
Keito Uchiyama <keito@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>
|
||||
Lily <qvang.j@gmail.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>
|
||||
Pieter Vanderwerff <pieter@heyday.co.nz>
|
||||
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 <aylott@fb.com>
|
||||
Thomas Aylott <oblivious@subtlegradient.com>
|
||||
Timothy Yung <yungsters@gmail.com>
|
||||
Tom Occhino <tomocchino@gmail.com>
|
||||
Ville Immonen <ville.immonen@iki.fi>
|
||||
Vjeux <vjeuxx@gmail.com>
|
||||
Wincent Colaiuta <win@wincent.com>
|
||||
Zach Bruggeman <zbruggeman@me.com>
|
||||
fxbois <fxbois@gmail.com>
|
||||
imagentleman <imagentlemail@gmail.com>
|
||||
|
||||
106
CHANGELOG.md
106
CHANGELOG.md
@@ -1,3 +1,109 @@
|
||||
## 0.10.0 (March 21, 2014)
|
||||
|
||||
### React Core
|
||||
|
||||
#### New Features
|
||||
* Added warnings to help migrate towards descriptors
|
||||
* Made it possible to server render without React-related markup (`data-reactid`, `data-react-checksum`). This DOM will not be mountable by React. [Read the docs for `React.renderComponentToStaticMarkup`](http://facebook.github.io/react/docs/top-level-api.html#react.rendercomponenttostaticmarkup)
|
||||
* Added support for more attributes:
|
||||
* `srcSet` for `<img>` to specify 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. [Read the docs](http://facebook.github.io/react/docs/update.html)
|
||||
|
||||
### 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).
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
206
Gruntfile.js
206
Gruntfile.js
@@ -3,116 +3,206 @@
|
||||
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('npm-react:release', npmReactTasks.buildRelease);
|
||||
grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
|
||||
grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.pack);
|
||||
|
||||
// Check that the version we're exporting is the same one we expect in the
|
||||
// package. This is not an ideal way to do this, but makes sure that we keep
|
||||
// them in sync.
|
||||
var reactVersionExp = /\bReact\.version\s*=\s*['"]([^'"]+)['"];/;
|
||||
grunt.registerTask('version-check', function() {
|
||||
var reactVersion = reactVersionExp.exec(
|
||||
grunt.file.read('./build/modules/React.js')
|
||||
)[1];
|
||||
var npmReactVersion = grunt.file.readJSON('./npm-react/package.json').version;
|
||||
var reactToolsVersion = grunt.config.data.pkg.version;
|
||||
grunt.registerTask('version-check', versionCheckTask);
|
||||
|
||||
if (reactVersion !== reactToolsVersion) {
|
||||
grunt.log.error(
|
||||
'React version does not match react-tools version. Expected %s, saw %s',
|
||||
reactToolsVersion,
|
||||
reactVersion
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (npmReactVersion !== reactToolsVersion) {
|
||||
grunt.log.error(
|
||||
'npm-react version does not match react-tools veersion. Expected %s, saw %s',
|
||||
reactToolsVersion,
|
||||
npmReactVersion
|
||||
);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('build:basic', ['jsx:debug', 'version-check', 'browserify:basic']);
|
||||
grunt.registerTask('build:addons', ['jsx:debug', 'browserify:addons']);
|
||||
grunt.registerTask('build:transformer', ['jsx:debug', 'browserify:transformer']);
|
||||
grunt.registerTask('build:min', ['jsx:release', 'version-check', 'browserify:min']);
|
||||
grunt.registerTask('build:addons-min', ['jsx:debug', 'browserify:addonsMin']);
|
||||
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',
|
||||
'version-check',
|
||||
'populist:jasmine',
|
||||
'populist:test'
|
||||
]);
|
||||
grunt.registerTask('build:npm-react', ['version-check', 'jsx:release', 'npm-react:release']);
|
||||
grunt.registerTask('build:npm-react', ['version-check', 'jsx:normal', 'npm-react:release']);
|
||||
|
||||
grunt.registerTask('test', ['build:test', 'build:basic', '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', function() {
|
||||
if (grunt.option('debug')) {
|
||||
grunt.task.run('build:test', 'build:basic', 'connect:server:keepalive');
|
||||
} else {
|
||||
grunt.task.run('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',
|
||||
'browserify:addons',
|
||||
'jsx:release',
|
||||
'browserify:min',
|
||||
'browserify:addonsMin',
|
||||
'npm-react:release',
|
||||
'npm-react:pack',
|
||||
'npm-react-tools:pack',
|
||||
'copy:react_docs',
|
||||
'compare_size'
|
||||
]);
|
||||
|
||||
12
README.md
12
README.md
@@ -10,7 +10,7 @@ React is a JavaScript library for building user interfaces.
|
||||
|
||||
## The `react` npm package has recently changed!
|
||||
|
||||
If you're looking for jeffbski's [React.js](https://github.com/jeffbski/react) project, it's now in `npm` as `reactjs` rather than `react`.
|
||||
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
|
||||
|
||||
@@ -32,7 +32,7 @@ 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/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.
|
||||
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
|
||||
|
||||
@@ -40,12 +40,12 @@ The fastest way to get started is to serve JavaScript from the CDN (also availab
|
||||
|
||||
```html
|
||||
<!-- The core React library -->
|
||||
<script src="http://fb.me/react-0.8.0.js"></script>
|
||||
<script src="http://fb.me/react-0.10.0.js"></script>
|
||||
<!-- In-browser JSX transformer, remove when pre-compiling JSX. -->
|
||||
<script src="http://fb.me/JSXTransformer-0.8.0.js"></script>
|
||||
<script src="http://fb.me/JSXTransformer-0.10.0.js"></script>
|
||||
```
|
||||
|
||||
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.
|
||||
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.10.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:
|
||||
|
||||
@@ -87,6 +87,8 @@ We use grunt to automate many tasks. Run `grunt -h` to see a mostly complete lis
|
||||
```sh
|
||||
# Build and run tests with PhantomJS
|
||||
grunt test
|
||||
# Build and run tests in your browser
|
||||
grunt test --debug
|
||||
# Lint the code with JSHint
|
||||
grunt lint
|
||||
# Wipe out build directory
|
||||
|
||||
20
bin/jsx
20
bin/jsx
@@ -1,12 +1,24 @@
|
||||
#!/usr/bin/env node
|
||||
// -*- mode: js -*-
|
||||
"use strict";
|
||||
|
||||
var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
|
||||
var visitors = require('../vendor/fbtransform/visitors');
|
||||
var transform = require('jstransform').transform;
|
||||
|
||||
require("commoner").resolve(function(id) {
|
||||
require('commoner').version(
|
||||
require('../package.json').version
|
||||
).resolve(function(id) {
|
||||
return this.readModuleP(id);
|
||||
}).process(function(id, source) {
|
||||
}).option(
|
||||
'--harmony',
|
||||
'Turns on JS transformations such as ES6 Classes etc.'
|
||||
).process(function(id, source) {
|
||||
// This is where JSX, ES6, etc. desugaring happens.
|
||||
return transform(visitors.react, source).code;
|
||||
var visitorList;
|
||||
if (this.options.harmony) {
|
||||
visitorList = visitors.getAllVisitors();
|
||||
} else {
|
||||
visitorList = visitors.transformVisitors.react;
|
||||
}
|
||||
return transform(visitorList, source).code;
|
||||
});
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#!/usr/bin/env node
|
||||
// -*- mode: js -*-
|
||||
"use strict";
|
||||
|
||||
var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
|
||||
var getAllVisitors = require('../vendor/fbtransform/visitors').getAllVisitors;
|
||||
var transform = require('jstransform').transform;
|
||||
var propagate = require("../vendor/constants").propagate;
|
||||
|
||||
require("commoner").resolve(function(id) {
|
||||
require("commoner").version(
|
||||
require("../package.json").version
|
||||
).resolve(function(id) {
|
||||
var context = this;
|
||||
|
||||
// Note that the result of context.getProvidedP() is cached for the
|
||||
@@ -28,7 +31,7 @@ require("commoner").resolve(function(id) {
|
||||
var constants = context.config.constants || {};
|
||||
|
||||
// This is where JSX, ES6, etc. desugaring happens.
|
||||
source = transform(visitors.react, source).code;
|
||||
source = transform(getAllVisitors(), source).code;
|
||||
|
||||
// Constant propagation means removing any obviously dead code after
|
||||
// replacing constant expressions with literal (boolean) values.
|
||||
|
||||
8
docs/404.md
Normal file
8
docs/404.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
layout: single
|
||||
title: Page Not Found
|
||||
---
|
||||
|
||||
We couldn't find what you were looking for.
|
||||
|
||||
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
|
||||
@@ -13,7 +13,7 @@ redcarpet:
|
||||
pygments: true
|
||||
name: React
|
||||
markdown: redcarpet
|
||||
react_version: 0.8.0
|
||||
react_version: 0.10.0
|
||||
description: A JavaScript library for building user interfaces
|
||||
relative_permalinks: true
|
||||
paginate: 5
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
@import '_solarized';
|
||||
|
||||
@mixin code-typography {
|
||||
font-family: 'source-code-pro', Menlo, 'Courier New', Consolas, monospace;
|
||||
font-size: 13px;
|
||||
line-height: 20px;
|
||||
font-family: 'source-code-pro', Menlo, Consolas, 'Courier New', monospace;
|
||||
font-size: 0.8em;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
$skinnyContentWidth: 650px;
|
||||
@@ -683,7 +683,12 @@ p code {
|
||||
}
|
||||
|
||||
.highlight pre code {
|
||||
font-size: inherit;
|
||||
/* Respect line-height defined in <code> styles above */
|
||||
display: block;
|
||||
|
||||
/* Cancel out styles for `li code` in case we have a <pre> within an <li>. */
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.highlight pre .lineno {
|
||||
@@ -749,3 +754,19 @@ p code {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
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: example-apps
|
||||
title: Example apps
|
||||
title: Complementary Tools
|
||||
- id: examples
|
||||
title: Examples
|
||||
- title: Guides
|
||||
items:
|
||||
- id: why-react
|
||||
@@ -45,8 +49,12 @@
|
||||
title: Two-Way Binding Helpers
|
||||
- id: class-name-manipulation
|
||||
title: Class Name Manipulation
|
||||
- id: examples
|
||||
title: Examples
|
||||
- id: test-utils
|
||||
title: Test Utilities
|
||||
- id: clone-with-props
|
||||
title: Cloning Components
|
||||
- id: update
|
||||
title: Immutability Helpers
|
||||
- title: Reference
|
||||
items:
|
||||
- id: top-level-api
|
||||
@@ -62,6 +70,12 @@
|
||||
- id: dom-differences
|
||||
title: DOM Differences
|
||||
- id: special-non-dom-attributes
|
||||
title: Special Non-DOM attributes
|
||||
title: Special Non-DOM Attributes
|
||||
- id: reconciliation
|
||||
title: Reconciliation
|
||||
- title: Flux
|
||||
items:
|
||||
- id: flux-overview
|
||||
title: Flux Overview
|
||||
- id: flux-todo-list
|
||||
title: Flux Todo List
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2013 Facebook, Inc.
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2013 Facebook, Inc.
|
||||
* 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.
|
||||
|
||||
@@ -21,6 +21,7 @@ React.renderComponent(
|
||||
codeText={HELLO_COMPONENT}
|
||||
renderCode={true}
|
||||
transformer={transformer}
|
||||
/>,
|
||||
showCompiledJSTab={false}
|
||||
/>,
|
||||
document.getElementById('jsxCompiler')
|
||||
);
|
||||
|
||||
@@ -85,7 +85,8 @@ var ReactPlayground = React.createClass({
|
||||
return {
|
||||
transformer: function(code) {
|
||||
return JSXTransformer.transform(code).code;
|
||||
}
|
||||
},
|
||||
showCompiledJSTab: true
|
||||
};
|
||||
},
|
||||
|
||||
@@ -116,7 +117,7 @@ var ReactPlayground = React.createClass({
|
||||
compiledCode = this.compileCode();
|
||||
} catch (err) {}
|
||||
|
||||
var jsContent =
|
||||
var JSContent =
|
||||
<CodeMirrorEditor
|
||||
key="js"
|
||||
className="playgroundStage CodeMirror-readonly"
|
||||
@@ -125,7 +126,7 @@ var ReactPlayground = React.createClass({
|
||||
readOnly={true}
|
||||
/>;
|
||||
|
||||
var jsxContent =
|
||||
var JSXContent =
|
||||
<CodeMirrorEditor
|
||||
key="jsx"
|
||||
onChange={this.handleCodeChange}
|
||||
@@ -138,22 +139,28 @@ var ReactPlayground = React.createClass({
|
||||
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 className="playground">
|
||||
<div>
|
||||
<div
|
||||
className={JSXTabClassName}
|
||||
onClick={this.handleCodeModeSwitch.bind(this, this.MODES.JSX)}>
|
||||
Live JSX Editor
|
||||
</div>
|
||||
<div
|
||||
className={JSTabClassName}
|
||||
onClick={this.handleCodeModeSwitch.bind(this, this.MODES.JS)}>
|
||||
Compiled JS
|
||||
</div>
|
||||
{JSXTab}
|
||||
{this.props.showCompiledJSTab && JSTab}
|
||||
</div>
|
||||
<div className="playgroundCode">
|
||||
{isJS ? jsContent : jsxContent}
|
||||
{isJS ? JSContent : JSXContent}
|
||||
</div>
|
||||
<div className="playgroundPreview">
|
||||
<div ref="mount" />
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<![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>
|
||||
<script type="text/javascript" src="/react/js/react.js"></script>
|
||||
<script type="text/javascript" src="/react/js/JSXTransformer.js"></script>
|
||||
<script type="text/javascript" src="/react/js/live_editor.js"></script>
|
||||
<script type="text/javascript" src="/react/js/showdown.js"></script>
|
||||
@@ -46,7 +46,7 @@
|
||||
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>
|
||||
@@ -74,7 +74,10 @@
|
||||
{{ content }}
|
||||
|
||||
<footer class="wrap">
|
||||
<div class="left">A Facebook & Instagram collaboration.</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>
|
||||
|
||||
@@ -19,7 +19,5 @@ sectionid: docs
|
||||
<a class="docs-next" href="/react/docs/{{ 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>
|
||||
|
||||
@@ -16,6 +16,5 @@ sectionid: blog
|
||||
</div>
|
||||
|
||||
<div class="fb-like" data-send="true" data-width="650" data-show-faces="false"></div>
|
||||
<div class="fb-comments" data-width="650" data-num-posts="10" data-href="{{ site.url }}{{ site.baseurl }}{{ page.url }}"></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -19,7 +19,5 @@ sectionid: tips
|
||||
<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>
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -75,7 +75,7 @@ some pretty cool things with it:
|
||||
- We've built internal prototypes that run React apps in a web worker and use
|
||||
React to drive **native iOS views** via an Objective-C bridge.
|
||||
- You can run React
|
||||
[on the server](http://github.com/petehunt/react-server-rendering)
|
||||
[on the server](http://github.com/petehunt/react-server-rendering-example)
|
||||
for SEO, performance, code sharing and overall flexibility.
|
||||
- Events behave in a consistent, standards-compliant way in all browsers
|
||||
(including IE8) and automatically use
|
||||
|
||||
@@ -68,6 +68,7 @@ In cases where you want to preserve the space adjacent to a newline, you can wri
|
||||
- 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
|
||||
|
||||
@@ -86,7 +87,7 @@ In cases where you want to preserve the space adjacent to a newline, you can wri
|
||||
- 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
|
||||
- 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
|
||||
|
||||
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://eliseumds.tumblr.com/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>
|
||||
72
docs/_posts/2014-03-19-react-v0.10-rc1.md
Normal file
72
docs/_posts/2014-03-19-react-v0.10-rc1.md
Normal file
@@ -0,0 +1,72 @@
|
||||
---
|
||||
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
|
||||
* Added warnings to help migrate towards descriptors
|
||||
* Made it possible to server render without React-related markup (`data-reactid`, `data-react-checksum`). This DOM will not be mountable by React. [Read the docs for `React.renderComponentToStaticMarkup`](/react/docs/top-level-api.html#react.rendercomponenttostaticmarkup)
|
||||
* Added support for more attributes:
|
||||
* `srcSet` for `<img>` to specify 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. [Read the docs](/react/docs/update.html)
|
||||
|
||||
### 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).
|
||||
73
docs/_posts/2014-03-21-react-v0.10.md
Normal file
73
docs/_posts/2014-03-21-react-v0.10.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
title: React v0.10
|
||||
layout: post
|
||||
author: Paul O’Shannessy
|
||||
---
|
||||
|
||||
Hot on the heels of the [release candidate earlier this week](/react/blog/2014/03/19/react-v0.10-rc1.html), we're ready to call v0.10 done. The only major issue we discovered had to do with the `react-tools` package, which has been updated. We've copied over the changelog from the RC with some small clarifying changes.
|
||||
|
||||
The release is available for download from the CDN:
|
||||
|
||||
* **React**
|
||||
Dev build with warnings: <http://fb.me/react-0.10.0.js>
|
||||
Minified build for production: <http://fb.me/react-0.10.0.min.js>
|
||||
* **React with Add-Ons**
|
||||
Dev build with warnings: <http://fb.me/react-with-addons-0.10.0.js>
|
||||
Minified build for production: <http://fb.me/react-with-addons-0.10.0.min.js>
|
||||
* **In-Browser JSX transformer**
|
||||
<http://fb.me/JSXTransformer-0.10.0.js>
|
||||
|
||||
We've also published version `0.10.0` 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
|
||||
* Added warnings to help migrate towards descriptors
|
||||
* Made it possible to server render without React-related markup (`data-reactid`, `data-react-checksum`). This DOM will not be mountable by React. [Read the docs for `React.renderComponentToStaticMarkup`](/react/docs/top-level-api.html#react.rendercomponenttostaticmarkup)
|
||||
* Added support for more attributes:
|
||||
* `srcSet` for `<img>` to specify 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. [Read the docs](/react/docs/update.html)
|
||||
|
||||
### 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).
|
||||
|
||||
57
docs/_posts/2014-03-28-the-road-to-1.0.md
Normal file
57
docs/_posts/2014-03-28-the-road-to-1.0.md
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
title: The Road to 1.0
|
||||
layout: post
|
||||
author: Paul O'Shannessy
|
||||
---
|
||||
|
||||
When we launched React last spring, we purposefully decided not to call it 1.0. It was production ready, but we had plans to evolve APIs and behavior as we saw how people were using React, both internally and externally. We've learned a lot over the past 9 months and we've thought a lot about what 1.0 will mean for React. A couple weeks ago, I outlined [several projects][projects] that we have planned to take us to 1.0 and beyond. Today I'm writing a bit more about them to give our users a better insight into our plans.
|
||||
|
||||
Our primary goal with 1.0 is to clarify our messaging and converge on an API that is aligned with our goals. In order to do that, we want to clean up bad patterns we've seen in use and really help enable developers write good code.
|
||||
|
||||
## Descriptors
|
||||
|
||||
The first part of this is what we're calling "descriptors". I talked about this briefly in our [v0.10 announcements][v0.10]. The goal here is to separate our virtual DOM representation from our use of it. Simply, this means the return value of a component (e.g. `React.DOM.div()`, `MyComponent()`) will be a simple object containing the information React needs to render. Currently the object returned is actually linked to React's internal representation of the component and even directly to the DOM element. This has enabled some bad patterns that are quite contrary to how we want people to use React. That's our failure.
|
||||
|
||||
We added some warnings in v0.9 to start migrating some of these bad patterns. With v0.10 we'll catch more. You'll see more on this soon as we expect to ship v0.11 with descriptors.
|
||||
|
||||
## API Cleanup
|
||||
|
||||
This is really connected to everything. We want to keep the API as simple as possible and help developers [fall into the pit of success][pitofsuccess]. Enabling bad patterns with bad APIs is not success.
|
||||
|
||||
## ES6
|
||||
|
||||
Before we even launched React publicly, members of the team were talking about how we could leverage ES6, namely classes, to improve the experience of creating React components. Calling `React.createClass(...)` isn't great. We don't quite have the right answer here yet, but we're close. We want to make sure we make this as simple as possible. It could look like this:
|
||||
|
||||
```js
|
||||
class MyComponent extends React.Component {
|
||||
render() {
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
There are other features of ES6 we're already using in core. I'm sure we'll see more of that. The `jsx` executable we ship with `react-tools` already supports transforming many parts of ES6 into code that will run on older browsers.
|
||||
|
||||
## Context
|
||||
|
||||
While we haven't documented `context`, it exists in some form in React already. It exists as a way to pass values through a tree without having to use props at every single point. We've seen this need crop up time and time again, so we want to make this as easy as possible. It's use has performance tradeoffs, and there are known weaknesses in our implementation, so we want to make sure this is a solid feature.
|
||||
|
||||
## Addons
|
||||
|
||||
As you may know, we ship a separate build of React with some extra features we called "addons". While this has served us fine, it's not great for our users. It's made testing harder, but also results in more cache misses for people using a CDN. The problem we face is that many of these "addons" need access to parts of React that we don't expose publicly. Our goal is to ship each addon on its own and let each hook into React as needed. This would also allow others to write and distribute "addons".
|
||||
|
||||
## Browser Support
|
||||
|
||||
As much as we'd all like to stop supporting older browsers, it's not always possible. Facebook still supports IE8. While React won't support IE8 forever, our goal is to have 1.0 support IE8. Hopefully we can continue to abstract some of these rough parts.
|
||||
|
||||
## Animations
|
||||
|
||||
Finding a way to define animations in a declarative way is a hard problem. We've been exploring the space for a long time. We've introduced some half-measures to alleviate some use cases, but the larger problem remains. While we'd like to make this a part of 1.0, realistically we don't think we'll have a good solution in place.
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
There are several other things I listed on [our projects page][projects] that we're tracking. Some of them are internals and have no obvious outward effect (improve tests, repo separation, updated test runner). I encourage you to take a look.
|
||||
|
||||
[v0.10]: http://facebook.github.io/react/blog/2014/03/21/react-v0.10.html
|
||||
[pitofsuccess]: http://blog.codinghorror.com/falling-into-the-pit-of-success/
|
||||
[projects]: https://github.com/facebook/react/wiki/Projects
|
||||
38
docs/_posts/2014-04-04-reactnet.md
Normal file
38
docs/_posts/2014-04-04-reactnet.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: "Use React and JSX in ASP.NET MVC"
|
||||
layout: post
|
||||
author: Daniel Lo Nigro
|
||||
---
|
||||
|
||||
Today we're happy to announce the initial release of
|
||||
[ReactJS.NET](http://reactjs.net/), which makes it easier to use React and JSX
|
||||
in .NET applications, focusing specifically on ASP.NET MVC web applications.
|
||||
It has several purposes:
|
||||
|
||||
- On-the-fly JSX to JavaScript compilation. Simply reference JSX files and they
|
||||
will be compiled and cached server-side.
|
||||
|
||||
```html
|
||||
<script src="@Url.Content("/Scripts/HelloWorld.jsx")"></script>
|
||||
```
|
||||
- JSX to JavaScript compilation via popular minification/combination libraries
|
||||
(Cassette and ASP.NET Bundling and Minification). This is suggested for
|
||||
production websites.
|
||||
- Server-side component rendering to make your initial render super fast.
|
||||
|
||||
Even though we are focusing on ASP.NET MVC, ReactJS.NET can also be used in
|
||||
Web Forms applications as well as non-web applications (for example, in build
|
||||
scripts). ReactJS.NET currently only works on Microsoft .NET but we are working
|
||||
on support for Linux and Mac OS X via Mono as well.
|
||||
|
||||
Installation
|
||||
------------
|
||||
ReactJS.NET is packaged in NuGet. Simply run `Install-Package React.Mvc4` in the
|
||||
package manager console or search NuGet for "React" to install it.
|
||||
[See the documentation](http://reactjs.net/docs) for more information. The
|
||||
GitHub project contains
|
||||
[a sample website](https://github.com/reactjs/React.NET/tree/master/src/React.Sample.Mvc4)
|
||||
demonstrating all of the features.
|
||||
|
||||
Let us know what you think, and feel free to send through any feedback and
|
||||
report bugs [on GitHub](https://github.com/reactjs/React.NET).
|
||||
17
docs/_posts/2014-05-06-flux.md
Normal file
17
docs/_posts/2014-05-06-flux.md
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: "Flux: An Application Architecture for React"
|
||||
layout: post
|
||||
author: Bill Fisher and Jing Chen
|
||||
---
|
||||
|
||||
We recently spoke at one of f8's breakout session about Flux, a data flow architecture that works well with React. Check out the video here:
|
||||
|
||||
<figure><iframe width="560" height="315" src="//www.youtube.com/embed/nYkdrAPrdcw?list=PLb0IAmt7-GS188xDYE-u1ShQmFFGbrk0v" frameborder="0" allowfullscreen></iframe></figure>
|
||||
|
||||
To summarize, Flux works well for us because the single directional data flow makes it easy to understand and modify an application as it becomes more complicated. We found that two-way data bindings lead to cascading updates, where changing one data model led to another data model updating, making it very difficult to predict what would change as the result of a single user interaction.
|
||||
|
||||
In Flux, the Dispatcher is a singleton that directs the flow of data and ensures that updates do not cascade. As an application grows, the Dispatcher becomes more vital, as it can also manage dependencies between stores by invoking the registered callbacks in a specific order.
|
||||
|
||||
When a user interacts with a React view, the view sends an action (usually represented as a JavaScript object with some fields) through the dispatcher, which notifies the various stores that hold the application's data and business logic. When the stores change state, they notify the views that something has updated. This works especially well with React's declarative model, which allows the stores to send updates without specifying how to transition views between states.
|
||||
|
||||
Flux is more of a pattern than a formal framework, so you can start using Flux immediately without a lot of new code. An [example of this architecture](https://github.com/facebook/react/tree/master/examples/todomvc-flux) is available, along with more [detailed documentation](http://facebook.github.io/react/docs/flux-overview.html) and a [tutorial](http://facebook.github.io/react/docs/flux-todo-list.html). Look for more examples to come in the future.
|
||||
15
docs/_posts/2014-05-29-one-year-of-open-source-react.md
Normal file
15
docs/_posts/2014-05-29-one-year-of-open-source-react.md
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "One Year of Open-Source React"
|
||||
layout: post
|
||||
author: Cheng Lou
|
||||
---
|
||||
|
||||
Today marks the one-year open-source anniversary of React.
|
||||
|
||||
It’s been a crazy ride. 2.3k commits and 1.5k issues and pull requests later, we’re approaching version 1.0 and nearing 7k Github stars, with big names such as Khan Academy, New York Times, and Airbnb (and naturally, Facebook and Instagram) using React in production, and many more developers blogging their success stories with it. The [roadmap](http://facebook.github.io/react/blog/2014/03/28/the-road-to-1.0.html) gives a glimpse into the future of the library; exciting stuff lies ahead!
|
||||
|
||||
Every success has its story. React was born out of our frustration at existing solutions for building UIs. When it was first suggested at Facebook, few people thought that functionally re-rendering everything and diffing the results could ever perform well. However, support grew after we built the first implementation and people wrote their first components. When we open-sourced React, the initial reception was [similarly skeptical](http://www.reddit.com/r/programming/comments/1fak87/react_facebooks_latest_javascript_client_library/). It challenges many pre-established conventions and received mostly disapproving first-impressions, intermingled with positive ones that often were votes of confidence in Facebook’s engineering capabilities. On an open, competitive platform such as the web, it's been hard to convince people to try React. [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html), in particular, filtered out a huge chunk of potential early adopters.
|
||||
|
||||
Fast forward one year, React has strongly [grown in popularity](https://news.ycombinator.com/item?id=7489959). Special acknowledgments go to Khan Academy, the ClojureScript community, and established frameworks such as Ember and Angular for contributing to and debating on our work. We'd also like to thank all the [individual contributors](https://github.com/facebook/react/graphs/contributors) who have taken the time to help out over the past year. React, as a library and as a new paradigm on the web, wouldn't have gained as much traction without them. In the future, we will continue to try to set an example of what's possible to achieve when we rethink about current “best practices”.
|
||||
|
||||
Here’s to another year!
|
||||
55
docs/_posts/2014-06-27-community-roundup-19.md
Normal file
55
docs/_posts/2014-06-27-community-roundup-19.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
title: "Community Round-up #19"
|
||||
layout: post
|
||||
author: Cheng Lou
|
||||
---
|
||||
|
||||
## React Meetups!
|
||||
Ever wanted to find developers who also share the same interest in React than you? Recently, there has been a React Meetup in [San Francisco](http://www.meetup.com/ReactJS-San-Francisco/) (courtesy of [Telmate](http://www.telmate.com)), and one in [London](http://www.meetup.com/London-React-User-Group/) (courtesy of [Stuart Harris](http://www.meetup.com/London-React-User-Group/members/105837542/), [Cain Ullah](http://www.meetup.com/London-React-User-Group/members/15509971/) and [Zoe Merchant](http://www.meetup.com/London-React-User-Group/members/137058242/)). These two events have been big successes; a second one in London is [already planned](http://www.meetup.com/London-React-User-Group/events/191406572/).
|
||||
|
||||
If you don't live near San Francisco or London, why not start one in your community?
|
||||
|
||||
## Complementary Tools
|
||||
In case you haven't seen it, we've consolidated the tooling solution around React on [this wiki page](https://github.com/facebook/react/wiki/Complementary-Tools). Some of the notable recent entries include:
|
||||
|
||||
- [Ryan Florence](https://github.com/rpflorence) and [Michael Jackson](https://github.com/mjackson)'s [react-nested-router](https://github.com/rpflorence/react-nested-router), which is a translation of the Ember router API to React.
|
||||
|
||||
- [Stephen J. Collings](https://github.com/stevoland)'s [react-bootstrap](https://github.com/react-bootstrap/react-bootstrap), which wraps the popular framework with a bit of React goodness. The [website](http://react-bootstrap.github.io/components.html) features live-editable demos.
|
||||
|
||||
- [Andrey Popp](https://github.com/andreypopp)'s [react-quickstart](https://github.com/andreypopp/react-quickstart), which gives you a quick template for server-side rendering and routing, among other features.
|
||||
|
||||
These are some of the links that often pop up on the #reactjs IRC channel. If you made something that you think deserves to be shown on the wiki, feel free to add it!
|
||||
|
||||
## React in Interesting Places
|
||||
|
||||
The core concepts React themselves is something very valuable that the community is exploring and pushing further. A year ago, we wouldn't have imagined something like [Bruce Hauman](http://rigsomelight.com)'s [Flappy Bird ClojureScript port](http://rigsomelight.com/2014/05/01/interactive-programming-flappy-bird-clojurescript.html), whose interactive programming has been made possible through React:
|
||||
|
||||
<iframe width="560" height="315" src="//www.youtube.com/embed/KZjFVdU8VLI" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
And don't forget [Pete Hunt](https://github.com/petehunt)'s Wolfenstein 3D rendering engine in React ([source code](https://github.com/petehunt/wolfenstein3D-react/blob/master/js/renderer.js#L183)). While it's nearly a year old, it's still a nice demo.
|
||||
|
||||
[](http://www.petehunt.net/wolfenstein3D-react/wolf3d.html)
|
||||
|
||||
Give us a shoutout on IRC or [React Google Groups](https://groups.google.com/forum/#!forum/reactjs) if you've used React in some Interesting places.
|
||||
|
||||
## Even More People Using React
|
||||
|
||||
### Prismatic
|
||||
[Prismatic](http://getprismatic.com/home) recently shrank their codebase fivefold with the help of React and its popular ClojureScript wrapper, [Om](https://github.com/swannodette/om). They detailed their very positive experience [here](http://blog.getprismatic.com/om-sweet-om-high-functional-frontend-engineering-with-clojurescript-and-react/).
|
||||
|
||||
> Finally, the state is normalized: each piece of information is represented in a single place. Since React ensures consistency between the DOM and the application data, the programmer can focus on ensuring that the state properly stays up to date in response to user input. If the application state is normalized, then this consistency is guaranteed by definition, completely avoiding the possibility of an entire class of common bugs.
|
||||
|
||||
### Adobe Brackets
|
||||
[Kevin Dangoor](http://www.kevindangoor.com) works on [Brackets](http://brackets.io/?lang=en), the open-source code editor. After writing [his first impression on React](http://www.kevindangoor.com/2014/05/simplifying-code-with-react/), he followed up with another insightful [article](http://www.kevindangoor.com/2014/05/react-in-brackets/) on how to gradually make the code transition, how to preserve the editor's good parts, and how to tune Brackets' tooling around JSX.
|
||||
|
||||
> We don’t need to switch to React everywhere, all at once. It’s not a framework that imposes anything on the application structure. [...] Easy, iterative adoption is definitely something in React’s favor for us.
|
||||
|
||||
### Storehouse
|
||||
[Storehouse](https://www.storehouse.co) (Apple Design Award 2014)'s web presence is build with React. Here's [an example story](https://www.storehouse.co/stories/y2ad-mexico-city-clouds). Congratulations on the award!
|
||||
|
||||
### Vim Awesome
|
||||
[Vim Awesome](http://vimawesome.com), an open-source Vim plugins directory built on React, was just launched. Be sure to [check out the source code](https://github.com/divad12/vim-awesome) if you're curious to see an example of how to build a small single-page React app.
|
||||
|
||||
## Random Tweets
|
||||
|
||||
<blockquote class="twitter-tweet" lang="en"><p>Spent 12 hours so far with <a href="https://twitter.com/hashtag/reactjs?src=hash">#reactjs</a>. Spent another 2 wondering why we've been doing JS frameworks wrong until now. React makes me happy.</p>— Paul Irwin (@paulirwin) <a href="https://twitter.com/paulirwin/statuses/481263947589242882">June 24, 2014</a></blockquote>
|
||||
147
docs/_posts/2014-07-13-react-v0.11-rc1.md
Normal file
147
docs/_posts/2014-07-13-react-v0.11-rc1.md
Normal file
@@ -0,0 +1,147 @@
|
||||
---
|
||||
title: React v0.11 RC
|
||||
layout: post
|
||||
author: Paul O’Shannessy
|
||||
---
|
||||
|
||||
It's that time again… we're just about ready to ship a new React release! v0.11 includes a wide array of bug fixes and features. We highlighted some of the most important changes below, along with the full changelog.
|
||||
|
||||
The release candidate is available for download from the CDN:
|
||||
|
||||
* **React**
|
||||
Dev build with warnings: <http://fb.me/react-0.11.0-rc1.js>
|
||||
Minified build for production: <http://fb.me/react-0.11.0-rc1.min.js>
|
||||
* **React with Add-Ons**
|
||||
Dev build with warnings: <http://fb.me/react-with-addons-0.11.0-rc1.js>
|
||||
Minified build for production: <http://fb.me/react-with-addons-0.11.0-rc1.min.js>
|
||||
* **In-Browser JSX transformer**
|
||||
<http://fb.me/JSXTransformer-0.11.0-rc1.js>
|
||||
|
||||
We've also published version `0.11.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.
|
||||
|
||||
|
||||
# Blog Post
|
||||
|
||||
## `getDefaultProps`
|
||||
|
||||
Starting in React 0.11, `getDefaultProps()` is called only once when `React.createClass()` is called, instead of each time a component is rendered. This means that `getDefaultProps()` can no longer vary its return value based on `this.props` and any objects will be shared across all instances. This change improves performance and will make it possible in the future to do PropTypes checks earlier in the rendering process, allowing us to give better error messages.
|
||||
|
||||
|
||||
## Rendering to `null`
|
||||
|
||||
Since React's release, people have been using work arounds to "render nothing". Usually this means returning an empty `<div/>` or `<span/>`. Some people even got clever and started returning `<noscript/>` to avoid extraneous DOM nodes. We finally provided a "blessed" solution that allows developers to writing meaningful code. Returning `null` in an explicit indication to React that you do not want anything rendered. Behind the scenes we make this work with a `<noscript>` element, though in the future we hope to not put anything in the document. In the mean time, `<noscript>` elements do not affect layout in any way, so you can feel safe using `null` today!
|
||||
|
||||
```js
|
||||
// Before
|
||||
render: function() {
|
||||
if (!this.state.visible) {
|
||||
return <span/>;
|
||||
}
|
||||
// ...
|
||||
}
|
||||
|
||||
// After
|
||||
render: function() {
|
||||
if (!this.state.visible) {
|
||||
return null;
|
||||
}
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## JSX Namespacing
|
||||
|
||||
Another feature request we've been hearing for a long time is the ability to have namespaces in JSX. Given that JSX is just JavaScript, we didn't want to use XML namespacing. Instead we opted for a standard JS approach: object property access. Instead of assigning variables to access components stored in an object (such as a component library), you can now use the component directly as `<Namespace.Component/>`.
|
||||
|
||||
```js
|
||||
// Before
|
||||
var UI = require('UI');
|
||||
var UILayout = UI.Layout;
|
||||
var UIButton = UI.Button;
|
||||
var UILabel = UI.Label;
|
||||
|
||||
render: function() {
|
||||
return <UILayout><UIButton /><UILabel>text</UILabel></UILayout>;
|
||||
}
|
||||
|
||||
// After
|
||||
var UI = require('UI');
|
||||
|
||||
render: function() {
|
||||
return <UI.Layout><UI.Button /><UI.Label>text</UI.Label></UI.Layout>;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Improved keyboard event normalization
|
||||
|
||||
Keyboard events now contain a normalized `e.key` value according to the [DOM Level 3 Events spec](http://www.w3.org/TR/DOM-Level-3-Events/#keys-special), allowing you to write simpler key handling code that works in all browsers, such as:
|
||||
|
||||
```js
|
||||
handleKeyDown: function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
// Handle enter key
|
||||
} else if (e.key === ' ') {
|
||||
// Handle spacebar
|
||||
} else if (e.key === 'ArrowLeft') {
|
||||
// Handle left arrow
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
Keyboard and mouse events also now include a normalized `e.getModifierState()` that works consistently across browsers.
|
||||
|
||||
## Changelog
|
||||
|
||||
### React Core
|
||||
|
||||
#### Breaking Changes
|
||||
* `getDefaultProps()` is now called once per class and shared across all instances
|
||||
|
||||
#### New Features
|
||||
* Rendering to `null`
|
||||
* Keyboard events include normalized `e.key` and `e.getModifierState()` properties
|
||||
* New normalized `onBeforeInput` event
|
||||
* `React.Children.count` has been added as a helper for counting the number of children
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* Re-renders are batched in more cases
|
||||
* Events: `e.view` properly normalized
|
||||
* Added Support for more HTML attributes (`coords`, `crossOrigin`, `download`, `hrefLang`, `mediaGroup`, `muted`, `scrolling`, `shape`, `srcSet`, `start`, `useMap`)
|
||||
* Improved SVG support
|
||||
* Changing `className` on a mounted SVG component now works correctly
|
||||
* Added support for elements `mask` and `tspan`
|
||||
* Added support for attributes `dx`, `dy`, `fillOpacity`, `fontFamily`, `fontSize`, `markerEnd`, `markerMid`, `markerStart`, `opacity`, `patternContentUnits`, `patternUnits`, `preserveAspectRatio`, `strokeDasharray`, `strokeOpacity`
|
||||
* CSS property names with vendor prefixes (`Webkit`, `ms`, `Moz`, `O`) are now handled properly
|
||||
* Duplicate keys no longer cause a hard error; now a warning is logged (and only one of the children with the same key is shown)
|
||||
* `img` event listeners are now unbound properly, preventing the error "Two valid but unequal nodes with the same `data-reactid`"
|
||||
* Added explicit warning when missing polyfills
|
||||
|
||||
### React With Addons
|
||||
* PureRenderMixin
|
||||
* Perf: a new set of tools to help with performance analysis
|
||||
* Update: New `$apply` command to transform values
|
||||
* TransitionGroup bug fixes with null elements, Android
|
||||
|
||||
### React NPM Module
|
||||
* Now includes the pre-built packages under `dist/`.
|
||||
* `envify` is properly listed as a dependency instead of a peer dependency
|
||||
|
||||
### JSX
|
||||
* Added support for namespaces, eg `<Components.Checkbox />`
|
||||
* JSXTransformer
|
||||
* Enable the same `harmony` features available in the command line with `<script type="text/jsx;harmony=true">`
|
||||
* Scripts are downloaded in parallel for more speed. They are still executed in order (as you would expect with normal script tags)
|
||||
* Fixed a bug preventing sourcemaps from working in Firefox
|
||||
|
||||
### React Tools Module
|
||||
* Improved readme with usage and API information
|
||||
* Improved ES6 transforms available with `--harmony` option
|
||||
* Added `--source-map-inline` option to the `jsx` executable
|
||||
* New `transformWithDetails` API which gives access to the raw sourcemap data
|
||||
|
||||
|
||||
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](https://www.npmjs.org/package/react) package name on npm and to [Christopher Aue](http://christopheraue.net/) for letting us use the [reactjs.com](http://reactjs.com/) domain name and the [@reactjs](https://twitter.com/reactjs) username on Twitter.
|
||||
@@ -20,7 +20,7 @@ sectionid: blog
|
||||
|
||||
<div class="pagination">
|
||||
{% if paginator.previous_page %}
|
||||
<a href="/react/{{ paginator.previous_page_path }}" class="previous">
|
||||
<a href="/react{{ paginator.previous_page_path }}" class="previous">
|
||||
« Previous Page
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
@@ -161,10 +161,20 @@ var content = Container(null, window.isLoggedIn ? Nav(null) : Login(null));
|
||||
|
||||
### Comments
|
||||
|
||||
It's easy to add comments within your JSX; they're just JS expressions:
|
||||
It's easy to add comments within your JSX; they're just JS expressions. You just need to be careful to put `{}` around the comments when you are within the children section of a tag.
|
||||
|
||||
```javascript
|
||||
var content = <Container>{/* this is a comment */}<Nav /></Container>;
|
||||
var content = (
|
||||
<Nav>
|
||||
{/* child comment, put {} around */}
|
||||
<Person
|
||||
/* multi
|
||||
line
|
||||
comment */
|
||||
name={window.isLoggedIn ? window.name : ''} // end of line comment
|
||||
/>
|
||||
</Nav>
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -13,17 +13,6 @@ JSX looks like HTML but there are some important differences you may run into.
|
||||
>
|
||||
> For DOM differences, such as the inline `style` attribute, check [here](/react/docs/dom-differences.html).
|
||||
|
||||
## 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.
|
||||
|
||||
|
||||
## HTML Entities
|
||||
|
||||
You can insert HTML entities within literal text in JSX:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
// A value of any data type
|
||||
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,6 +117,26 @@ 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
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ next: working-with-the-browser.html
|
||||
|
||||
Form components such as `<input>`, `<textarea>`, and `<option>` differ from other native components because they can be mutated via user interactions. These components provide interfaces that make it easier to manage forms in response to user interactions.
|
||||
|
||||
For information on events on `<form>` see [Form Events](/react/docs/events.html#form-events).
|
||||
|
||||
## Interactive Props
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -127,19 +121,23 @@ In addition to that philosophy, we've also taken the stance that we, as authors
|
||||
* `Array.prototype.some`
|
||||
* `Date.now`
|
||||
* `Function.prototype.bind`
|
||||
* `Object.keys`
|
||||
|
||||
`es5-sham.js`, also from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim), provides the following that React needs:
|
||||
|
||||
* `Object.create`
|
||||
* `Object.freeze`
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
@@ -15,7 +15,7 @@ Consider the case when you wish to tell an `<input />` element (that exists with
|
||||
getInitialState: function() {
|
||||
return {userInput: ''};
|
||||
},
|
||||
handleKeyUp: function(e) {
|
||||
handleChange: function(e) {
|
||||
this.setState({userInput: e.target.value});
|
||||
},
|
||||
clearAndFocusInput: function() {
|
||||
@@ -26,11 +26,11 @@ Consider the case when you wish to tell an `<input />` element (that exists with
|
||||
return (
|
||||
<div>
|
||||
<div onClick={this.clearAndFocusInput}>
|
||||
Click To Focus and Reset
|
||||
Click to Focus and Reset
|
||||
</div>
|
||||
<input
|
||||
value={this.state.userInput}
|
||||
onKeyUp={this.handleKeyUp}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -72,17 +72,19 @@ React supports a very special property that you can attach to any component that
|
||||
|
||||
It's as simple as:
|
||||
|
||||
**1.** Assign a `ref` attribute to anything returned from `render` such as:
|
||||
1. Assign a `ref` attribute to anything returned from `render` such as:
|
||||
|
||||
```html
|
||||
<input ref="myInput" />
|
||||
```
|
||||
```html
|
||||
<input ref="myInput" />
|
||||
```
|
||||
|
||||
**2.** In some other code (typically event handler code), access the **backing instance** via `this.refs` as in:
|
||||
2. In some other code (typically event handler code), access the **backing instance** via `this.refs` as in:
|
||||
|
||||
```javascript
|
||||
```javascript
|
||||
this.refs.myInput
|
||||
```
|
||||
```
|
||||
|
||||
You can access the component's DOM node directly by calling `this.refs.myInput.getDOMNode()`.
|
||||
|
||||
## Completing the Example
|
||||
|
||||
@@ -91,23 +93,26 @@ It's as simple as:
|
||||
getInitialState: function() {
|
||||
return {userInput: ''};
|
||||
},
|
||||
handleKeyUp: function(e) {
|
||||
handleChange: function(e) {
|
||||
this.setState({userInput: e.target.value});
|
||||
},
|
||||
clearAndFocusInput: function() {
|
||||
this.setState({userInput: ''}); // Clear the input
|
||||
this.refs.theInput.getDOMNode().focus(); // Boom! Focused!
|
||||
// Clear the input
|
||||
this.setState({userInput: ''}, function() {
|
||||
// This code executes after the component is re-rendered
|
||||
this.refs.theInput.getDOMNode().focus(); // Boom! Focused!
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<div onClick={this.clearAndFocusInput}>
|
||||
Click To Focus and Reset
|
||||
Click to Focus and Reset
|
||||
</div>
|
||||
<input
|
||||
ref="theInput"
|
||||
value={this.state.userInput}
|
||||
onKeyUp={this.handleKeyUp}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -132,4 +137,4 @@ Refs are a great way to send a message to a particular child instance in a way t
|
||||
|
||||
- *Never* access refs inside of any component's render method - or while any component's render method is even running anywhere in the call stack.
|
||||
- If you want to preserve Google Closure Compiler Crushing resilience, make sure to never access as a property what was specified as a string. This means you must access using `this.refs['myRefString']` if your ref was defined as `ref="myRefString"`.
|
||||
- If you have not programmed several apps with React, your first inclination is usually going to be to try to use refs to "make things happen" in your app. If this is the case, take a moment and think more critically about where `state` should be owned in the component hierarchy. Often, it becomes clear that the proper place to "own" that state is at a higher level in the hierarchy. Placing the state there often eliminates any desire to use `ref`s to "make things happen" - instead, the data flow will usually accomplish your goal.
|
||||
- If you have not programmed several apps with React, your first inclination is usually going to be to try to use refs to "make things happen" in your app. If this is the case, take a moment and think more critically about where `state` should be owned in the component hierarchy. Often, it becomes clear that the proper place to "own" that state is at a higher level in the hierarchy. Placing the state there often eliminates any desire to use `ref`s to "make things happen" – instead, the data flow will usually accomplish your goal.
|
||||
|
||||
@@ -38,20 +38,4 @@ If you have [npm](http://npmjs.org/), you can simply run `npm install -g react-t
|
||||
|
||||
### Helpful Open-Source Projects
|
||||
|
||||
The open-source community has built tools that integrate JSX with several build systems.
|
||||
|
||||
* [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
|
||||
* [gulp-react](https://github.com/sindresorhus/gulp-react) - [gulp](http://gulpjs.com/) task for JSX
|
||||
* [jsx-requirejs-plugin](https://github.com/philix/jsx-requirejs-plugin) - use JSX with [require.js](http://requirejs.org/) and precompile JSX files with r.js
|
||||
* [pyReact](https://github.com/facebook/react-python) - use JSX with [Python](http://www.python.org/)
|
||||
* [react-rails](https://github.com/facebook/react-rails) - use JSX with [Ruby on Rails](http://rubyonrails.org/)
|
||||
|
||||
|
||||
### 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`.
|
||||
* Linting provides accurate line numbers after compiling without sourcemaps.
|
||||
* Elements use standard scoping so linters can find usage of out-of-scope components.
|
||||
The open-source community has built tools that integrate JSX with several editors and build systems. See [JSX integrations](https://github.com/facebook/react/wiki/Complementary-Tools#jsx-integrations) for the full list.
|
||||
|
||||
@@ -9,8 +9,11 @@ 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`, for dealing with animations and transitions that are usually not simple to implement, such as before a component's removal.
|
||||
- `ReactLink`, to simplify the coordination between user's form input data and and the component's state.
|
||||
- `classSet`, for manipulating the DOM `class` string a bit more cleanly.
|
||||
- [`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).
|
||||
- [`cloneWithProps()`](clone-with-props.html), to make shallow copies of React components and change their props.
|
||||
- [`update()`](update.html), a helper function that makes dealing with immutable data in JavaScript easier.
|
||||
|
||||
To get the add-ons, use `react-with-addons.js` (and its minified counterpart) rather than the common `react.js`.
|
||||
|
||||
@@ -7,16 +7,20 @@ prev: addons.html
|
||||
next: two-way-binding-helpers.html
|
||||
---
|
||||
|
||||
`ReactTransitions` 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.
|
||||
React provides a `ReactTransitionGroup` addon component as a low-level API for animation, and a `ReactCSSTransitionGroup` for easily implementing basic CSS animations and transitions.
|
||||
|
||||
## Getting Started
|
||||
## High-level API: `ReactCSSTransitionGroup`
|
||||
|
||||
`ReactTransitionGroup` 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.
|
||||
`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.
|
||||
|
||||
```javascript{22-24}
|
||||
### 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{30-32}
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var ReactTransitionGroup = React.addons.TransitionGroup;
|
||||
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
|
||||
|
||||
var TodoList = React.createClass({
|
||||
getInitialState: function() {
|
||||
@@ -29,7 +33,7 @@ var TodoList = React.createClass({
|
||||
},
|
||||
handleRemove: function(i) {
|
||||
var newItems = this.state.items;
|
||||
newItems.splice(i, 1)
|
||||
newItems.splice(i, 1);
|
||||
this.setState({items: newItems});
|
||||
},
|
||||
render: function() {
|
||||
@@ -42,17 +46,17 @@ var TodoList = React.createClass({
|
||||
}.bind(this));
|
||||
return (
|
||||
<div>
|
||||
<div><button onClick={this.handleAdd} /></div>
|
||||
<ReactTransitionGroup transitionName="example">
|
||||
<button onClick={this.handleAdd}>Add Item</button>
|
||||
<ReactCSSTransitionGroup transitionName="example">
|
||||
{items}
|
||||
</ReactTransitionGroup>
|
||||
</ReactCSSTransitionGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
In this component, when a new item is added to `ReactTransitionGroup` 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.
|
||||
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:
|
||||
|
||||
@@ -67,7 +71,7 @@ You can use these classes to trigger a CSS animation or transition. For example,
|
||||
}
|
||||
```
|
||||
|
||||
You'll notice that when you try to remove an item `ReactTransitionGroup` 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 `ReactTransitionGroup` keeps your DOM elements on the page until the animation completes. Try adding this CSS:
|
||||
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 {
|
||||
@@ -80,18 +84,36 @@ You'll notice that when you try to remove an item `ReactTransitionGroup` keeps i
|
||||
}
|
||||
```
|
||||
|
||||
## Disabling Animations
|
||||
### 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 `ReactTransitionGroup` waits for an animation to complete before removing your DOM node. You can add `transitionEnter={false}` or `transitionLeave={false}` props to `ReactTransitionGroup` to disable these 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.
|
||||
|
||||
## Rendering a Different Component
|
||||
## 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{3}
|
||||
<ReactTransitionGroup
|
||||
transitionName="example"
|
||||
component={React.DOM.ul}>
|
||||
```javascript{1}
|
||||
<ReactTransitionGroup component={React.DOM.ul}>
|
||||
...
|
||||
</ReactTransitionGroup>
|
||||
```
|
||||
|
||||
@@ -66,6 +66,8 @@ var WithLink = React.createClass({
|
||||
|
||||
`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.
|
||||
|
||||
@@ -4,7 +4,7 @@ title: Class Name Manipulation
|
||||
layout: docs
|
||||
permalink: class-name-manipulation.html
|
||||
prev: two-way-binding-helpers.html
|
||||
next: examples.html
|
||||
next: test-utils.html
|
||||
---
|
||||
|
||||
`classSet()` is a neat utility for easily manipulating the DOM `class` string.
|
||||
|
||||
141
docs/docs/09.4-test-utils.md
Normal file
141
docs/docs/09.4-test-utils.md
Normal file
@@ -0,0 +1,141 @@
|
||||
---
|
||||
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}(DOMElement element, object eventData)
|
||||
```
|
||||
|
||||
Simulate an event dispatch on a DOM node with optional `eventData` event data. **This is possibly the single most useful utility in `ReactTestUtils`.**
|
||||
|
||||
Example usage:
|
||||
|
||||
```javascript
|
||||
var node = this.refs.input.getDOMNode();
|
||||
React.addons.TestUtils.Simulate.click(node);
|
||||
React.addons.TestUtils.Simulate.change(node);
|
||||
React.addons.TestUtils.Simulate.keyDown(node, {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(ReactComponent 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.
|
||||
14
docs/docs/09.5-clone-with-props.md
Normal file
14
docs/docs/09.5-clone-with-props.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
id: clone-with-props
|
||||
title: Cloning Components
|
||||
layout: docs
|
||||
permalink: clone-with-props.html
|
||||
prev: test-utils.html
|
||||
next: update.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.
|
||||
62
docs/docs/09.6-update.md
Normal file
62
docs/docs/09.6-update.md
Normal file
@@ -0,0 +1,62 @@
|
||||
---
|
||||
id: update
|
||||
title: Immutability Helpers
|
||||
layout: docs
|
||||
permalink: update.html
|
||||
prev: clone-with-props.html
|
||||
---
|
||||
|
||||
React lets you use whatever style of data management you want, including mutation. However, if you can use immutable data in performance-critical parts of your application it's easy to implement a fast `shouldComponentUpdate()` method to significantly speed up your app.
|
||||
|
||||
Dealing with immutable data in JavaScript is more difficult than in languages designed for it, like [Clojure](http://clojure.org/). However, we've provided a simple immutability helper, `update()`, that makes dealing with this type of data much easier, *without* fundamentally changing how your data is represented.
|
||||
|
||||
## The main idea
|
||||
|
||||
If you mutate data like this:
|
||||
|
||||
```javascript
|
||||
myData.x.y.z = 7;
|
||||
myData.a.b.push(9);
|
||||
```
|
||||
|
||||
you have no way of determining which data has changed since the previous copy is destroyed. Instead, you need to create a new copy of `myData` and change only the parts of it that need to be changed. Then you can compare the old copy of `myData` with the new one in `shouldComponentUpdate()` using triple-equals:
|
||||
|
||||
```javascript
|
||||
var newData = deepCopy(myData);
|
||||
newData.x.y.z = 7;
|
||||
newData.a.b.push(9);
|
||||
```
|
||||
|
||||
Unfortunately, deep copies are expensive, and sometimes impossible. You can alleviate this by only copying objects that need to be changed and by reusing the objects that haven't changed. Unfortunately, in today's JavaScript this can be cumbersome:
|
||||
|
||||
```javascript
|
||||
var newData = extend(myData, {
|
||||
x: extend(myData.x, {
|
||||
y: extend(myData.x.y, {z: 7}),
|
||||
}),
|
||||
a: extend(myData.a, {b: myData.a.b.concat(9)})
|
||||
});
|
||||
```
|
||||
|
||||
While this is fairly performant (since it only shallow copies `log n` objects and reuses the rest), it's a big pain to write. Look at all the repetition! This is not only annoying, but also provides a large surface area for bugs.
|
||||
|
||||
`update()` provides simple syntactic sugar around this pattern to make writing this code easier. This code becomes:
|
||||
|
||||
```javascript
|
||||
var newData = React.addons.update(myData, {
|
||||
x: {y: {z: {$set: 7}}},
|
||||
a: {b: {$push: [7]}}
|
||||
});
|
||||
```
|
||||
|
||||
While the syntax takes a little getting used to (though it's inspired by [MongoDB's query language](http://docs.mongodb.org/manual/core/crud-introduction/#query)) there's no redundancy, it's statically analyzable and it's not much more typing than the mutative version.
|
||||
|
||||
The `$`-prefixed keys are called *directives*. The data structure they are "mutating" is called the *target*.
|
||||
|
||||
## Available directives
|
||||
|
||||
* `{$push: array}` `push()` all the items in `array` on the target
|
||||
* `{$unshift: array}` `unshift()` all the items in `array` on the target
|
||||
* `{$splice: array of arrays}` for each item in `array()` call `splice()` on the target with the parameters provided by the item.
|
||||
* `{$set: any}` replace the target entirely
|
||||
* `{$merge: object}` merge the keys of `object` with the target
|
||||
@@ -1,21 +0,0 @@
|
||||
---
|
||||
id: examples
|
||||
title: Examples
|
||||
layout: docs
|
||||
permalink: examples.html
|
||||
prev: class-name-manipulation.html
|
||||
---
|
||||
|
||||
### 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 most new JS development.
|
||||
|
||||
|
||||
### Sample Code
|
||||
|
||||
* We've included [a step-by-step comment box tutorial](/react/docs/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/).
|
||||
* [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.
|
||||
@@ -4,43 +4,7 @@ title: Complementary Tools
|
||||
layout: docs
|
||||
permalink: complementary-tools.html
|
||||
prev: videos.html
|
||||
next: example-apps.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
|
||||
|
||||
### Full-stack starter kits
|
||||
|
||||
* **[react-app](https://github.com/andreypopp/react-app)** Rapid appliaction development with React with 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](https://backbonejs.org/)** (for an example see [github-issues-viewer](https://github.com/jaredly/github-issues-viewer))
|
||||
|
||||
### 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
|
||||
|
||||
### 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
|
||||
This page has moved to the [GitHub wiki](https://github.com/facebook/react/wiki/Complementary-Tools).
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
id: example-apps
|
||||
title: Example apps
|
||||
layout: docs
|
||||
permalink: example-apps.html
|
||||
prev: complementary-tools.html
|
||||
---
|
||||
|
||||
Here is a selection of open-source apps built with React.
|
||||
|
||||
* **[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-issues-viewer](https://github.com/jaredly/github-issues-viewer)**
|
||||
* **[hn-react](https://github.com/prabirshrestha/hn-react)** Dead-simple Hacker News client in React
|
||||
28
docs/docs/examples.md
Normal file
28
docs/docs/examples.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
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.
|
||||
* **[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.
|
||||
97
docs/docs/flux-overview.md
Normal file
97
docs/docs/flux-overview.md
Normal file
@@ -0,0 +1,97 @@
|
||||
---
|
||||
id: flux-overview
|
||||
title: Flux Application Architecture
|
||||
layout: docs
|
||||
next: flux-todo-list.html
|
||||
---
|
||||
|
||||
Flux is the application architecture that Facebook uses for building client-side web applications. It complements React's composable view components by utilizing a unidirectional data flow. It's more of a pattern rather than a formal framework, and you can start using Flux immediately without a lot of new code.
|
||||
|
||||
<figure><iframe width="560" height="315" src="//www.youtube.com/embed/nYkdrAPrdcw?list=PLb0IAmt7-GS188xDYE-u1ShQmFFGbrk0v" frameborder="0" allowfullscreen></iframe></figure>
|
||||
|
||||
Flux applications have three major parts: the dispatcher, the stores, and the views (React components). These should not be confused with Model-View-Controller. Controllers do exist in a Flux application, but they are controller-views — views often found at the top of the hierarchy that retrieve data from the stores and pass this data down to their children. Additionally, actions — dispatcher helper methods — are often used to support a semantic dispatcher API. It can be useful to think of them as a fourth part of the Flux update cycle.
|
||||
|
||||
Flux eschews MVC in favor of a unidirectional data flow. When a user interacts with a React view, the view propagates an action through a central dispatcher, to the various stores that hold the application's data and business logic, which updates all of the views that are affected. This works especially well with React's declarative programming style, which allows the store to send updates without specifying how to transition views between states.
|
||||
|
||||
We originally set out to deal correctly with derived data: for example, we wanted to show an unread count for message threads while another view showed a list of threads, with the unread ones highlighted. This was difficult to handle with MVC — marking a single thread as read would update the thread model, and then also need to update the unread count model. These dependencies and cascading updates often occur in a large MVC application, leading to a tangled weave of data flow and unpredictable results.
|
||||
|
||||
Control is inverted with stores: the stores accept updates and reconcile them as appropriate, rather than depending on something external to update its data in a consistent way. Nothing outside the store has any insight into how it manages the data for its domain, helping to keep a clear separation of concerns. This also makes stores more testable than models, especially since stores have no direct setter methods like `setAsRead()`, but instead have only an input point for the payload, which is delivered through the dispatcher and originates with actions.
|
||||
|
||||
|
||||
## Structure and Data Flow
|
||||
|
||||
Data in a Flux application flows in a single direction, in a cycle:
|
||||
|
||||
<pre>
|
||||
Views ---> (actions) ----> Dispatcher ---> (registered callback) ---> Stores -------+
|
||||
Ʌ |
|
||||
| V
|
||||
+-- (Controller-Views "change" event handlers) ---- (Stores emit "change" events) --+
|
||||
</pre>
|
||||
|
||||
A unidirectional data flow is central to the Flux pattern, and in fact Flux takes its name from the Latin word for flow. In the above diagram, the dispatcher, stores and views are independent nodes with distinct inputs and outputs. The actions are simply discrete, semantic helper functions that facilitate passing data to the dispatcher.
|
||||
|
||||
All data flows through the dispatcher as a central hub. Actions most often originate from user interactions with the views, and are nothing more than a call into the dispatcher. The dispatcher then invokes the callbacks that the stores have registered with it, effectively dispatching the data payload contained in the actions to all stores. Within their registered callbacks, stores determine which actions they are interested in, and respond accordingly. The stores then emit a "change" event to alert the controller-views that a change to the data layer has occurred. Controller-views listen for these events and retrieve data from the stores in an event handler. The controller-views call their own `render()` method via `setState()` or `forceUpdate()`, updating themselves and all of their children.
|
||||
|
||||
This structure allows us to reason easily about our application in a way that is reminiscent of functional reactive programming, or more specifically data-flow programming or flow-based programming, where data flows through the application in a single direction — there are no two-way bindings. Application state is maintained only in the stores, allowing the different parts of the application to remain highly decoupled. Where dependencies do occur between stores, they are kept in a strict hierarchy, with synchronous updates managed by the dispatcher.
|
||||
|
||||
We found that two-way data bindings led to cascading updates, where changing one object led to another object changing, which could also trigger more updates. As applications grew, these cascading updates made it very difficult to predict what would change as the result of one user interaction. When updates can only change data within a single round, the system as a whole becomes more predictable.
|
||||
|
||||
Let's look at the various parts of the Flux update cycle up close. A good place to start is the dispatcher.
|
||||
|
||||
|
||||
### A Single Dispatcher
|
||||
|
||||
The dispatcher is the central hub that manages all data flow in a Flux application. It is essentially a registry of callbacks into the stores. Each store registers itself and provides a callback. When the dispatcher responds to an action, all stores in the application are sent the data payload provided by the action via the callbacks in the registry.
|
||||
|
||||
As an application grows, the dispatcher becomes more vital, as it can manage dependencies between stores by invoking the registered callbacks in a specific order. Stores can declaratively wait for other stores to finish updating, and then update themselves accordingly.
|
||||
|
||||
|
||||
### Stores
|
||||
|
||||
Stores contain the application state and logic. Their role is somewhat similar to a model in a traditional MVC, but they manage the state of many objects — they are not instances of one object. Nor are they the same as Backbone's collections. More than simply managing a collection of ORM-style objects, stores manage the application state for a particular __domain__ within the application.
|
||||
|
||||
For example, Facebook's [Lookback Video Editor](https://facebook.com/lookback/edit) utilized a TimeStore that kept track of the playback time position and the playback state. On the other hand, the same application's ImageStore kept track of a collection of images. The TodoStore in our [TodoMVC example](https://github.com/facebook/react/tree/master/examples/todomvc-flux) is similar in that it manages a collection of to-do items. A store exhibits characteristics of both a collection of models and a singleton model of a logical domain.
|
||||
|
||||
As mentioned above, a store registers itself with the dispatcher and provides it with a callback. This callback receives the action's data payload as a parameter. The payload contains a type attribute, identifying the action's type. Within the store's registered callback, a switch statement based on the action's type is used to interpret the payload and to provide the proper hooks into the store's internal methods. This allows an action to result in an update to the state of the store, via the dispatcher. After the stores are updated, they broadcast an event declaring that their state has changed, so the views may query the new state and update themselves.
|
||||
|
||||
|
||||
### Views and Controller-Views
|
||||
|
||||
React provides the kind of composable views we need for the view layer. Close to the top of the nested view hierarchy, a special kind of view listens for events that are broadcast by the stores that it depends on. One could call this a controller-view, as it provides the glue code to get the data from the stores and to pass this data down the chain of its descendants. We might have one of these controller-views governing any significant section of the page.
|
||||
|
||||
When it receives the event from the store, it first requests the new data it needs via the stores' public getter methods. It then calls its own `setState()` or `forceUpdate()` methods, causing its `render()` method and the `render()` method of all its descendants to run.
|
||||
|
||||
We often pass the entire state of the store down the chain of views in a single object, allowing different descendants to use what they need. In addition to keeping the controller-like behavior at the top of the hierarchy, and thus keeping our descendant views as functionally pure as possible, passing down the entire state of the store in a single object also has the effect of reducing the number of props we need to manage.
|
||||
|
||||
Occasionally we may need to add additional controller-views deeper in the hierarchy to keep components simple. This might help us to better encapsulate a section of the hierarchy related to a specific data domain. Be aware, however, that controller-views deeper in the hierarchy can violate the singular flow of data by introducing a new, potentially conflicting entry point for the data flow. In making the decision of whether to add a deep controller-view, balance the gain of simpler components against the complexity of multiple data updates flowing into the hierarchy at different points. These multiple data updates can lead to odd effects, with React's render method getting invoked repeatedly by updates from different controller-views, potentially increasing the difficulty of debugging.
|
||||
|
||||
|
||||
### Actions
|
||||
|
||||
The dispatcher exposes a method that allows a view to trigger a dispatch to the stores, and to include a payload of data, or an action. The action construction may be wrapped into a semantic helper method which sends the payload to the dispatcher. For example, we may want to change the text of a to-do item in a to-do list application. We would create an action with a function signature like `updateText(todoId, newText)` in our `TodoActions` module. This method may be invoked from within our views' event handlers, so we can call it in response to a user action. This action method also adds the action type to the payload, so that when the payload is interpreted in the store, it can respond appropriately to a payload with a particular action type. In our example, this type might be named something like `TODO_UPDATE_TEXT`.
|
||||
|
||||
Actions may also come from other places, such as the server. This happens, for example, during data initialization. It may also happen when the server returns an error code or when the server has updates to provide to the application. We'll talk more about server actions in a future article. In this post we're only concerned with the basics of the data flow.
|
||||
|
||||
|
||||
### What About that Dispatcher?
|
||||
|
||||
As mentioned earlier, the dispatcher is also able to manage dependencies between stores. This functionality is available through the `waitFor()` method within the Dispatcher class. We did not need to use this method within the extremely simple [TodoMVC application](https://github.com/facebook/react/tree/master/examples/todomvc-flux), but we have included it [in the example dispatcher](https://github.com/facebook/react/blob/master/examples/todomvc-flux/js/dispatcher/Dispatcher.js#L110) as an example of what a dispatcher should be able to do in a larger, more complex application.
|
||||
|
||||
Within the TodoStore's registered callback we could explicitly wait for any dependencies to first update before moving forward:
|
||||
|
||||
```javascript
|
||||
case 'TODO_CREATE':
|
||||
Dispatcher.waitFor([
|
||||
PrependedTextStore.dispatcherIndex,
|
||||
YetAnotherStore.dispatcherIndex
|
||||
], function() {
|
||||
TodoStore.create(PrependedTextStore.getText() + ' ' + action.text);
|
||||
TodoStore.emit('change');
|
||||
});
|
||||
break;
|
||||
```
|
||||
|
||||
The arguments for `waitFor()` are an array of dipatcher registry indexes, and a final callback to invoke after the callbacks at the given indexes have completed. Thus the store that is invoking `waitFor()` can depend on the state of another store to inform how it should update its own state.
|
||||
|
||||
A problem arises if we create circular dependencies. If Store A waits for Store B, and B waits for A, then we'll have a very bad situation on our hands. We'll need a more robust dispatcher that flags these circular dependencies with console errors, and this is not easily accomplished with promises. Unfortunately, that's a bit beyond the scope of this documentation. In the future we hope to cover how to build a more robust dispatcher and how to initialize, update, and save the state of the application with persistent data, like a web service API.
|
||||
608
docs/docs/flux-todo-list.md
Normal file
608
docs/docs/flux-todo-list.md
Normal file
@@ -0,0 +1,608 @@
|
||||
---
|
||||
id: flux-todo-list
|
||||
title: Flux TodoMVC Tutorial
|
||||
layout: docs
|
||||
prev: flux-overview.html
|
||||
---
|
||||
|
||||
To demonstrate the Flux architecture with some example code, let's take on the classic TodoMVC application. The entire application is available in the React GitHub repo within the [todomvc-flux](https://github.com/facebook/react/tree/master/examples/todomvc-flux) example directory, but let's walk through the development of it a step at a time.
|
||||
|
||||
To begin, we'll need some boilerplate and get up and running with a module system. Node's module system, based on CommonJS, will fit the bill very nicely and we can build off of [react-boilerplate](https://github.com/petehunt/react-boilerplate) to get up and running quickly. Assuming you have npm installed, simply clone the react-boilerplate code from GitHub, and navigate into the resulting directory in Terminal (or whatever CLI application you like). Next run the npm scripts to get up and running: `npm install`, then `npm run build`, and lastly `npm start` to continuously build using Browserify.
|
||||
|
||||
The TodoMVC example has all this built into it as well, but if you're starting with react-boilerplate make sure you edit your package.json file to match the file structure and dependencies described in the TodoMVC example's [package.json](https://github.com/facebook/react/tree/master/examples/todomvc-flux/package.json), or else your code won't match up with the explanations below.
|
||||
|
||||
|
||||
Source Code Structure
|
||||
---------------------
|
||||
The resulting index.js file may be used as the entry point into our app, but we'll put most of our code in a 'js' directory. Let's let Browserify do its thing, and now we'll open a new tab in Terminal (or a GUI file browser) to look at the directory. It should look something like this:
|
||||
|
||||
```
|
||||
myapp
|
||||
|
|
||||
+ ...
|
||||
+ js
|
||||
|
|
||||
+ app.js
|
||||
+ bundle.js // generated by Browserify whenever we make changes.
|
||||
+ index.html
|
||||
+ ...
|
||||
```
|
||||
|
||||
Next we'll dive into the js directory, and layout our application's primary directory structure:
|
||||
|
||||
```
|
||||
myapp
|
||||
|
|
||||
+ ...
|
||||
+ js
|
||||
|
|
||||
+ actions
|
||||
+ components // all React components, both views and controller-views
|
||||
+ constants
|
||||
+ dispatcher
|
||||
+ stores
|
||||
+ app.js
|
||||
+ bundle.js
|
||||
+ index.html
|
||||
+ ...
|
||||
```
|
||||
|
||||
Creating a Dispatcher
|
||||
---------------------
|
||||
|
||||
Now we are ready to create a dispatcher. Here is an naive example of a Dispatcher class, written with JavaScript promises, polyfilled with Jake Archibald's [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) module.
|
||||
|
||||
```javascript
|
||||
var Promise = require('es6-promise').Promise;
|
||||
var merge = require('react/lib/merge');
|
||||
|
||||
var _callbacks = [];
|
||||
var _promises = [];
|
||||
|
||||
/**
|
||||
* Add a promise to the queue of callback invocation promises.
|
||||
* @param {function} callback The Store's registered callback.
|
||||
* @param {object} payload The data from the Action.
|
||||
*/
|
||||
var _addPromise = function(callback, payload) {
|
||||
_promises.push(new Promise(function(resolve, reject) {
|
||||
if (callback(payload)) {
|
||||
resolve(payload);
|
||||
} else {
|
||||
reject(new Error('Dispatcher callback unsuccessful'));
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
* Empty the queue of callback invocation promises.
|
||||
*/
|
||||
var _clearPromises = function() {
|
||||
_promises = [];
|
||||
};
|
||||
|
||||
var Dispatcher = function() {};
|
||||
Dispatcher.prototype = merge(Dispatcher.prototype, {
|
||||
|
||||
/**
|
||||
* Register a Store's callback so that it may be invoked by an action.
|
||||
* @param {function} callback The callback to be registered.
|
||||
* @return {number} The index of the callback within the _callbacks array.
|
||||
*/
|
||||
register: function(callback) {
|
||||
_callbacks.push(callback);
|
||||
return _callbacks.length - 1; // index
|
||||
},
|
||||
|
||||
/**
|
||||
* dispatch
|
||||
* @param {object} payload The data from the action.
|
||||
*/
|
||||
dispatch: function(payload) {
|
||||
_callbacks.forEach(function(callback) {
|
||||
_addPromise(callback, payload);
|
||||
});
|
||||
Promise.all(_promises).then(_clearPromises);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Dispatcher;
|
||||
```
|
||||
|
||||
The public API of this basic Dispatcher consists of only two methods: register() and dispatch(). We'll use register() within our stores to register each store's callback. We'll use dispatch() within our actions to trigger the invocation of the callbacks.
|
||||
|
||||
Now we are all set to create a dispatcher that is more specific to our app, which we'll call AppDispatcher.
|
||||
|
||||
```javascript
|
||||
var Dispatcher = require('./Dispatcher');
|
||||
|
||||
var merge = require('react/lib/merge');
|
||||
|
||||
var AppDispatcher = merge(Dispatcher.prototype, {
|
||||
|
||||
/**
|
||||
* A bridge function between the views and the dispatcher, marking the action
|
||||
* as a view action. Another variant here could be handleServerAction.
|
||||
* @param {object} action The data coming from the view.
|
||||
*/
|
||||
handleViewAction: function(action) {
|
||||
this.dispatch({
|
||||
source: 'VIEW_ACTION',
|
||||
action: action
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = AppDispatcher;
|
||||
```
|
||||
|
||||
Now we've created an implementation that is a bit more specific to our needs, with a helper function we can use in the actions coming from our views' event handlers. We might expand on this later to provide a separate helper for server updates, but for now this is all we need.
|
||||
|
||||
|
||||
Creating Stores
|
||||
----------------
|
||||
|
||||
We can use Node's EventEmitter to get started with a store. We need EventEmitter to broadcast the 'change' event to our controller-views. So let's take a look at what that looks like. I've omitted some of the code for the sake of brevity, but for the full version see [TodoStore.js](https://github.com/Facebook/react/blob/master/examples/todomvc-flux/js/stores/TodoStore.js) in the TodoMVC example code.
|
||||
|
||||
```javascript
|
||||
var AppDispatcher = require('../dispatcher/AppDispatcher');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var TodoConstants = require('../constants/TodoConstants');
|
||||
var merge = require('react/lib/merge');
|
||||
|
||||
var CHANGE_EVENT = 'change';
|
||||
|
||||
var _todos = {}; // collection of todo items
|
||||
|
||||
/**
|
||||
* Create a TODO item.
|
||||
* @param {string} text The content of the TODO
|
||||
*/
|
||||
function create(text) {
|
||||
// Using the current timestamp in place of a real id.
|
||||
var id = Date.now();
|
||||
_todos[id] = {
|
||||
id: id,
|
||||
complete: false,
|
||||
text: text
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a TODO item.
|
||||
* @param {string} id
|
||||
*/
|
||||
function destroy(id) {
|
||||
delete _todos[id];
|
||||
}
|
||||
|
||||
var TodoStore = merge(EventEmitter.prototype, {
|
||||
|
||||
/**
|
||||
* Get the entire collection of TODOs.
|
||||
* @return {object}
|
||||
*/
|
||||
getAll: function() {
|
||||
return _todos;
|
||||
},
|
||||
|
||||
emitChange: function() {
|
||||
this.emit(CHANGE_EVENT);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {function} callback
|
||||
*/
|
||||
addChangeListener: function(callback) {
|
||||
this.on(CHANGE_EVENT, callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {function} callback
|
||||
*/
|
||||
removeChangeListener: function(callback) {
|
||||
this.removeListener(CHANGE_EVENT, callback);
|
||||
}
|
||||
|
||||
dispatcherIndex: AppDispatcher.register(function(payload) {
|
||||
var action = payload.action;
|
||||
var text;
|
||||
|
||||
switch(action.actionType) {
|
||||
case TodoConstants.TODO_CREATE:
|
||||
text = action.text.trim();
|
||||
if (text !== '') {
|
||||
create(text);
|
||||
TodoStore.emitChange();
|
||||
}
|
||||
break;
|
||||
|
||||
case TodoConstants.TODO_DESTROY:
|
||||
destroy(action.id);
|
||||
TodoStore.emitChange();
|
||||
break;
|
||||
|
||||
// add more cases for other actionTypes, like TODO_UPDATE, etc.
|
||||
}
|
||||
|
||||
return true; // No errors. Needed by promise in Dispatcher.
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
module.exports = TodoStore;
|
||||
```
|
||||
|
||||
There are a few important things to note in the above code. To start, we are maintaining a private data structure called _todos. This object contains all the individual to-do items. Because this variable lives outside the class, but within the closure of the module, it remains private — it cannot be directly changed from the outside. This helps us preserve a distinct input/output interface for the flow of data by making it impossible to update the store without using an action.
|
||||
|
||||
Another important part is the registration of the store's callback with the dispatcher. We pass in our payload handling callback to the dispatcher and preserve the index that this store has in the dispatcher's registry. The callback function currently only handles one actionType, but later we can add as many as we need.
|
||||
|
||||
|
||||
Listening to Changes with a Controller-View
|
||||
-------------------------------------------
|
||||
|
||||
We need a React component near the top of our component hierarchy to listen for changes in the store. In a larger app, we would have more of these listening components, perhaps one for every section of the page. In Facebook's Ads Creation Tool, we have many of these controller-like views, each governing a specific section of the UI. In the Lookback Video Editor, we only had two: one for the animated preview and one for the image selection interface. Here's one for our TodoMVC example. Again, this is slightly abbreviated, but for the full code you can take a look at the TodoMVC example's [TodoApp.react.js](https://github.com/facebook/react/blob/master/examples/todomvc-flux/js/components/TodoApp.react.js)
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var Footer = require('./Footer.react');
|
||||
var Header = require('./Header.react');
|
||||
var MainSection = require('./MainSection.react');
|
||||
var React = require('react');
|
||||
var TodoStore = require('../stores/TodoStore');
|
||||
|
||||
function getTodoState() {
|
||||
return {
|
||||
allTodos: TodoStore.getAll()
|
||||
};
|
||||
}
|
||||
|
||||
var TodoApp = React.createClass({
|
||||
|
||||
getInitialState: function() {
|
||||
return getTodoState();
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
TodoStore.addChangeListener(this._onChange);
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
TodoStore.removeChangeListener(this._onChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {object}
|
||||
*/
|
||||
render: function() {
|
||||
return (
|
||||
<div>
|
||||
<Header />
|
||||
<MainSection
|
||||
allTodos={this.state.allTodos}
|
||||
areAllComplete={this.state.areAllComplete}
|
||||
/>
|
||||
<Footer allTodos={this.state.allTodos} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
_onChange: function() {
|
||||
this.setState(getTodoState());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = TodoApp;
|
||||
```
|
||||
|
||||
Now we're in our familiar React territory, utilizing React's lifecycle methods. We set up the initial state of this controller-view in getInitialState(), register an event listener in componentDidMount(), and then clean up after ourselves within componentWillUnmount(). We render a containing div and pass down the collection of states we got from the TodoStore.
|
||||
|
||||
The Header component contains the primary text input for the application, but it does not need to know the state of the store. The MainSection and Footer do need this data, so we pass it down to them.
|
||||
|
||||
More Views
|
||||
----------
|
||||
At a high level, the React component hierarchy of the app looks like this:
|
||||
|
||||
```javascript
|
||||
<TodoApp>
|
||||
<Header>
|
||||
<TodoTextInput />
|
||||
|
||||
<MainSection>
|
||||
<ul>
|
||||
<TodoItem />
|
||||
</ul>
|
||||
</MainSection>
|
||||
|
||||
</TodoApp>
|
||||
```
|
||||
If a TodoItem is in edit mode, it will also render a TodoTextInput as a child. Let's take a look at how some of these components display the data they receive as props, and how they communicate through actions with the dispatcher.
|
||||
The MainSection needs to iterate over the collection of to-do items it received from TodoApp to create the list of TodoItems. In the component's render() method, we can do that iteration like so:
|
||||
|
||||
```javascript
|
||||
var allTodos = this.props.allTodos;
|
||||
|
||||
for (var key in allTodos) {
|
||||
todos.push(<TodoItem key={key} todo={allTodos[key]} />);
|
||||
}
|
||||
|
||||
return (
|
||||
<section id="main">
|
||||
<ul id="todo-list">{todos}</ul>
|
||||
);
|
||||
```
|
||||
Now each TodoItem can display it's own text, and perform actions utilizing it's own ID. Explaining all the different actions that a TodoItem can invoke in the TodoMVC example goes beyond the scope of this article, but let's just take a look at the action that deletes one of the to-do items. Here is an abbreviated version of the TodoItem:
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var React = require('react');
|
||||
var TodoActions = require('../actions/TodoActions');
|
||||
var TodoTextInput = require('./TodoTextInput.react');
|
||||
|
||||
var TodoItem = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
todo: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var todo = this.props.todo;
|
||||
|
||||
return (
|
||||
<li
|
||||
key={todo.id}>
|
||||
<label>
|
||||
{todo.text}
|
||||
</label>
|
||||
<button className="destroy" onClick={this._onDestroyClick} />
|
||||
</li>
|
||||
);
|
||||
},
|
||||
|
||||
_onDestroyClick: function() {
|
||||
TodoActions.destroy(this.props.todo.id);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = TodoItem;
|
||||
```
|
||||
|
||||
With a destroy action available in our library of TodoActions, and a store ready to handle it, connecting the user's interaction with application state changes could not be simpler. We just wrap our onClick handler around the destroy action, provide it with the id, and we're done. Now the user can click the destroy button and kick off the Flux cycle to update the rest of the application.
|
||||
|
||||
Text input, on the other hand, is just a bit more complicated because we need to hang on to the state of the text input within the React component itself. Let's take a look at how TodoTextInput works.
|
||||
|
||||
As you'll see below, with every change to the input, React expects us to update the state of the component. So when we are finally ready to save the text inside the input, we will put the value held in the component's state in the action's payload. This is UI state, rather than application state, and keeping that distinction in mind is a good guide for where state should live. All application state should live in the store, while components occasionally hold on to UI state. Ideally, React components preserve as little state as possible.
|
||||
|
||||
Because TodoTextInput is being used in multiple places within our application, with different behaviors, we'll need to pass the onSave method in as a prop from the component's parent. This allows onSave to invoke different actions depending on where it is used.
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var React = require('react');
|
||||
var ReactPropTypes = React.PropTypes;
|
||||
|
||||
var ENTER_KEY_CODE = 13;
|
||||
|
||||
var TodoTextInput = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
className: ReactPropTypes.string,
|
||||
id: ReactPropTypes.string,
|
||||
placeholder: ReactPropTypes.string,
|
||||
onSave: ReactPropTypes.func.isRequired,
|
||||
value: ReactPropTypes.string
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return {
|
||||
value: this.props.value || ''
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {object}
|
||||
*/
|
||||
render: function() /*object*/ {
|
||||
return (
|
||||
<input
|
||||
className={this.props.className}
|
||||
id={this.props.id}
|
||||
placeholder={this.props.placeholder}
|
||||
onBlur={this._save}
|
||||
onChange={this._onChange}
|
||||
onKeyDown={this._onKeyDown}
|
||||
value={this.state.value}
|
||||
autoFocus={true}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Invokes the callback passed in as onSave, allowing this component to be
|
||||
* used in different ways.
|
||||
*/
|
||||
_save: function() {
|
||||
this.props.onSave(this.state.value);
|
||||
this.setState({
|
||||
value: ''
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {object} event
|
||||
*/
|
||||
_onChange: function(/*object*/ event) {
|
||||
this.setState({
|
||||
value: event.target.value
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {object} event
|
||||
*/
|
||||
|
||||
_onKeyDown: function(event) {
|
||||
if (event.keyCode === ENTER_KEY_CODE) {
|
||||
this._save();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = TodoTextInput;
|
||||
```
|
||||
|
||||
The Header passes in the onSave method as a prop to allow the TodoTextInput to create new
|
||||
to-do items:
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var React = require('react');
|
||||
var TodoActions = require('../actions/TodoActions');
|
||||
var TodoTextInput = require('./TodoTextInput.react');
|
||||
|
||||
var Header = React.createClass({
|
||||
|
||||
/**
|
||||
* @return {object}
|
||||
*/
|
||||
render: function() {
|
||||
return (
|
||||
<header id="header">
|
||||
<h1>todos</h1>
|
||||
<TodoTextInput
|
||||
id="new-todo"
|
||||
placeholder="What needs to be done?"
|
||||
onSave={this._onSave}
|
||||
/>
|
||||
</header>
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Event handler called within TodoTextInput.
|
||||
* Defining this here allows TodoTextInput to be used in multiple places
|
||||
* in different ways.
|
||||
* @param {string} text
|
||||
*/
|
||||
_onSave: function(text) {
|
||||
TodoActions.create(text);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = Header;
|
||||
```
|
||||
|
||||
In a different context, such as in editing mode for an existing to-do item, we might pass an onSave callback that invokes `TodoActions.update(text)` instead.
|
||||
|
||||
|
||||
Creating Semantic Actions
|
||||
-------------------------
|
||||
|
||||
Here is the basic code for the two actions we used above in our views:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* TodoActions
|
||||
*/
|
||||
|
||||
var AppDispatcher = require('../dispatcher/AppDispatcher');
|
||||
var TodoConstants = require('../constants/TodoConstants');
|
||||
|
||||
var TodoActions = {
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
create: function(text) {
|
||||
AppDispatcher.handleViewAction({
|
||||
actionType: TodoConstants.TODO_CREATE,
|
||||
text: text
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
*/
|
||||
destroy: function(id) {
|
||||
AppDispatcher.handleViewAction({
|
||||
actionType: TodoConstants.TODO_DESTROY,
|
||||
id: id
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
module.exports = TodoActions;
|
||||
```
|
||||
|
||||
As you can see, we really would not need to have the helpers AppDispatcher.handleViewAction() or TodoActions.create(). We could, in theory, call AppDispatcher.dispatch() directly and provide a payload. But as our application grows, having these helpers keeps the code clean and semantic. It's just a lot cleaner to write TodoActions.destroy(id) instead of writing a whole lot of things that our TodoItem shouldn't have to know about.
|
||||
|
||||
The payload produced by the TodoActions.create() will look like:
|
||||
|
||||
```javascript
|
||||
{
|
||||
source: 'VIEW_ACTION',
|
||||
action: {
|
||||
type: 'TODO_CREATE',
|
||||
text: 'Write blog post about Flux'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This payload is provided to the TodoStore through its registered callback. The TodoStore then broadcasts the 'change' event, and the MainSection responds by fetching the new collection of to-do items from the TodoStore and changing its state. This change in state causes the TodoApp component to call its own render() method, and the render() method of all of its descendents.
|
||||
|
||||
Start Me Up
|
||||
-----------
|
||||
|
||||
The bootstrap file of our application is app.js. It simply takes the TodoApp component and renders it in the root element of the application.
|
||||
|
||||
```javascript
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var React = require('react');
|
||||
|
||||
var TodoApp = require('./components/TodoApp.react');
|
||||
|
||||
React.renderComponent(
|
||||
<TodoApp />,
|
||||
document.getElementById('todoapp')
|
||||
);
|
||||
```
|
||||
|
||||
Adding Dependency Management to the Dispatcher
|
||||
----------------------------------------------
|
||||
|
||||
As I said previously, our Dispatcher implementation is a bit naive. It's pretty good, but it will not suffice for most applications. We need a way to be able to manage dependencies between Stores. Let's add that functionality with a waitFor() method within the main body of the Dispatcher class.
|
||||
|
||||
We'll need another public method, waitFor().
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* @param {array} promisesIndexes
|
||||
* @param {function} callback
|
||||
*/
|
||||
waitFor: function(promiseIndexes, callback) {
|
||||
var selectedPromises = _promises.filter(function(/*object*/ _, /*number*/ j) {
|
||||
return promiseIndexes.indexOf(j) !== -1;
|
||||
});
|
||||
Promise.all(selectedPromises).then(callback);
|
||||
}
|
||||
```
|
||||
|
||||
Now within the TodoStore callback we can explicitly wait for any dependencies to first update before moving forward. However, if Store A waits for Store B, and B waits for A, then a circular dependency will occur. A more robust dispatcher is required to flag this scenario with warnings in the console.
|
||||
|
||||
The Future of Flux
|
||||
------------------
|
||||
|
||||
A lot of people ask if Facebook will release Flux as an open source framework. Really, Flux is just an architecture, not a framework. But perhaps a Flux boilerplate project might make sense, if there is enough interest. Please let us know if you'd like to see us do this.
|
||||
|
||||
Thanks for taking the time to read about how we build client-side applications at Facebook. We hope Flux proves as useful to you as it has to us.
|
||||
@@ -11,6 +11,35 @@ next: component-api.html
|
||||
`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.
|
||||
@@ -69,9 +98,18 @@ Remove a mounted React component from the DOM and clean up its event handlers an
|
||||
### React.renderComponentToString
|
||||
|
||||
```javascript
|
||||
renderComponentToString(ReactComponent component, function callback)
|
||||
string renderComponentToString(ReactComponent component)
|
||||
```
|
||||
|
||||
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 can 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.
|
||||
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.
|
||||
|
||||
|
||||
### React.renderComponentToStaticMarkup
|
||||
|
||||
```javascript
|
||||
string renderComponentToStaticMarkup(ReactComponent component)
|
||||
```
|
||||
|
||||
Similar to `renderComponentToString`, except this doesn't create extra DOM attributes such as `data-react-id`, that React uses internally. This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save lots of bytes.
|
||||
|
||||
@@ -9,7 +9,7 @@ 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.
|
||||
Component classes created by `React.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
|
||||
@@ -24,20 +24,24 @@ If this component has been mounted into the DOM, this returns the corresponding
|
||||
### setProps
|
||||
|
||||
```javascript
|
||||
setProps(object nextProps)
|
||||
setProps(object nextProps[, function callback])
|
||||
```
|
||||
|
||||
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.
|
||||
When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `React.renderComponent()`.
|
||||
|
||||
Though calling `React.renderComponent()` again on the same node is the preferred way to update a root-level component, you can also call `setProps()` to change its properties and trigger a re-render. In addition, you can supply an optional callback function that is executed once `setProps` is completed and the component is re-rendered.
|
||||
|
||||
> 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()`.
|
||||
> When possible, the declarative approach of calling `React.renderComponent()` again is preferred; it tends to make updates easier to reason about. (There's no significant performance difference between the two approaches.)
|
||||
>
|
||||
> This method can only be called on a root-level component. That is, it's only available on the component passed directly to `React.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)
|
||||
replaceProps(object nextProps[, function callback])
|
||||
```
|
||||
|
||||
Like `setProps()` but deletes any pre-existing props instead of merging the two objects.
|
||||
@@ -76,7 +80,7 @@ Properties that are specified directly on the target component instance (such as
|
||||
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.
|
||||
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 and the component is re-rendered.
|
||||
|
||||
> Notes:
|
||||
>
|
||||
|
||||
@@ -67,6 +67,31 @@ The `mixins` array allows you to use mixins to share behavior among multiple com
|
||||
<!-- 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
|
||||
@@ -93,13 +118,17 @@ Invoked once, immediately before the initial rendering occurs. If you call `setS
|
||||
### Mounting: componentDidMount
|
||||
|
||||
```javascript
|
||||
componentDidMount(DOMElement rootNode)
|
||||
componentDidMount()
|
||||
```
|
||||
|
||||
Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via the `rootNode` argument or by calling `this.getDOMNode()`.
|
||||
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
|
||||
|
||||
@@ -166,13 +195,17 @@ Use this as an opportunity to perform preparation before an update occurs.
|
||||
### Updating: componentDidUpdate
|
||||
|
||||
```javascript
|
||||
componentDidUpdate(object prevProps, object prevState, DOMElement rootNode)
|
||||
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
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ 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
|
||||
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
|
||||
@@ -31,7 +31,8 @@ title tr track u ul var video wbr
|
||||
The following SVG elements are supported:
|
||||
|
||||
```
|
||||
circle g line path polygon polyline rect svg text
|
||||
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).
|
||||
@@ -49,25 +50,28 @@ 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 autoCapitalize
|
||||
accept accessKey action allowFullScreen allowTransparency alt async
|
||||
autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked
|
||||
className colSpan content contentEditable contextMenu controls data dateTime
|
||||
dir disabled draggable encType form frameBorder height hidden href htmlFor
|
||||
httpEquiv icon id label lang list loop max maxLength method min multiple name
|
||||
pattern placeholder poster preload radioGroup readOnly rel required role
|
||||
rowSpan scrollLeft scrollTop selected size spellCheck src step style tabIndex
|
||||
target title type value width wmode
|
||||
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
|
||||
```
|
||||
|
||||
The non-standard `autoCapitalize` attribute is supported for Mobile Safari.
|
||||
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.
|
||||
|
||||
In addition, there is the React-specific attribute `dangerouslySetInnerHTML` ([more here](/react/docs/special-non-dom-attributes.html)), used for directly inserting DOM strings into a component.
|
||||
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
|
||||
spreadMethod stopColor stopOpacity stroke strokeLinecap strokeWidth textAnchor transform
|
||||
version viewBox x1 x2 x y1 y2 y
|
||||
```
|
||||
|
||||
@@ -108,7 +108,7 @@ Event names:
|
||||
```
|
||||
onClick onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave
|
||||
onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
|
||||
onMouseMove onMouseUp
|
||||
onMouseMove onMouseOut onMouseOver onMouseUp
|
||||
```
|
||||
|
||||
Properties:
|
||||
|
||||
@@ -9,7 +9,7 @@ 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.
|
||||
* 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.
|
||||
|
||||
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/n25pd/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/t53sx/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/F8H7p/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 :)
|
||||
@@ -3,10 +3,10 @@ id: tutorial
|
||||
title: Tutorial
|
||||
layout: docs
|
||||
prev: getting-started.html
|
||||
next: videos.html
|
||||
next: thinking-in-react.html
|
||||
---
|
||||
|
||||
We'll be building a simple, but realistic comments box that you can drop into a blog, similar to Disqus, LiveFyre or Facebook comments.
|
||||
We'll be building a simple, but realistic comments box that you can drop into a blog, a basic version of the realtime comments offered by Disqus, LiveFyre or Facebook comments.
|
||||
|
||||
We'll provide:
|
||||
|
||||
@@ -22,7 +22,7 @@ It'll also have a few neat features:
|
||||
|
||||
### Want to skip all this and just see the source?
|
||||
|
||||
[It's all on GitHub.](https://github.com/petehunt/react-tutorial)
|
||||
[It's all on GitHub.](https://github.com/reactjs/react-tutorial)
|
||||
|
||||
### Getting started
|
||||
|
||||
@@ -40,9 +40,7 @@ For this tutorial we'll use prebuilt JavaScript files on a CDN. Open up your fav
|
||||
<body>
|
||||
<div id="content"></div>
|
||||
<script type="text/jsx">
|
||||
/**
|
||||
* @jsx React.DOM
|
||||
*/
|
||||
/** @jsx React.DOM */
|
||||
// The above declaration must remain intact at the top of the script.
|
||||
// Your code here
|
||||
</script>
|
||||
@@ -91,10 +89,9 @@ The first thing you'll notice is the XML-ish syntax in your JavaScript. We have
|
||||
var CommentBox = React.createClass({
|
||||
render: function() {
|
||||
return (
|
||||
React.DOM.div({
|
||||
className: 'commentBox',
|
||||
children: 'Hello, world! I am a CommentBox.'
|
||||
})
|
||||
React.DOM.div({className: "commentBox"},
|
||||
"Hello, world! I am a CommentBox."
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -210,12 +207,13 @@ Markdown is a simple way to format your text inline. For example, surrounding te
|
||||
|
||||
First, add the third-party **Showdown** library to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground):
|
||||
|
||||
```html{6}
|
||||
```html{7}
|
||||
<!-- template.html -->
|
||||
<head>
|
||||
<title>Hello React</title>
|
||||
<script src="http://fb.me/react-{{site.react_version}}.js"></script>
|
||||
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
|
||||
</head>
|
||||
```
|
||||
@@ -303,12 +301,16 @@ React.renderComponent(
|
||||
|
||||
Now that the data is available in the `CommentList`, let's render the comments dynamically:
|
||||
|
||||
```javascript{4-6}
|
||||
```javascript{4-10,13}
|
||||
// tutorial10.js
|
||||
var CommentList = React.createClass({
|
||||
render: function() {
|
||||
var commentNodes = this.props.data.map(function (comment) {
|
||||
return <Comment author={comment.author}>{comment.text}</Comment>;
|
||||
return (
|
||||
<Comment author={comment.author}>
|
||||
{comment.text}
|
||||
</Comment>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<div className="commentList">
|
||||
@@ -386,13 +388,13 @@ var CommentBox = React.createClass({
|
||||
},
|
||||
componentWillMount: function() {
|
||||
$.ajax({
|
||||
url: 'comments.json',
|
||||
url: this.props.url,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error("comments.json", status, err.toString());
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
@@ -408,9 +410,9 @@ var CommentBox = React.createClass({
|
||||
});
|
||||
```
|
||||
|
||||
Here, `componentWillMount` is a method called automatically by React before a component is rendered. The key to dynamic updates is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is trivial to add live updates. We will use simple polling here but you could easily use WebSockets or other technologies.
|
||||
Here, `componentWillMount` is a method called automatically by React before a component is rendered. The key to dynamic updates is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is only a minor change to add live updates. We will use simple polling here but you could easily use WebSockets or other technologies.
|
||||
|
||||
```javascript{3,16-17,31}
|
||||
```javascript{3,19-20,34}
|
||||
// tutorial14.js
|
||||
var CommentBox = React.createClass({
|
||||
loadCommentsFromServer: function() {
|
||||
@@ -419,6 +421,9 @@ var CommentBox = React.createClass({
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
@@ -470,7 +475,7 @@ var CommentForm = React.createClass({
|
||||
|
||||
Let's make the form interactive. When the user submits the form, we should clear it, submit a request to the server, and refresh the list of comments. To start, let's listen for the form's submit event and clear it.
|
||||
|
||||
```javascript{3-13,16-17,21}
|
||||
```javascript{3-13,16-18}
|
||||
// tutorial16.js
|
||||
var CommentForm = React.createClass({
|
||||
handleSubmit: function() {
|
||||
@@ -488,11 +493,7 @@ var CommentForm = React.createClass({
|
||||
return (
|
||||
<form className="commentForm" onSubmit={this.handleSubmit}>
|
||||
<input type="text" placeholder="Your name" ref="author" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Say something..."
|
||||
ref="text"
|
||||
/>
|
||||
<input type="text" placeholder="Say something..." ref="text" />
|
||||
<input type="submit" value="Post" />
|
||||
</form>
|
||||
);
|
||||
@@ -516,7 +517,7 @@ When a user submits a comment, we will need to refresh the list of comments to i
|
||||
|
||||
We need to pass data from the child component to its parent. We do this by passing a `callback` in props from parent to child:
|
||||
|
||||
```javascript{12-14,28}
|
||||
```javascript{15-17,30}
|
||||
// tutorial17.js
|
||||
var CommentBox = React.createClass({
|
||||
loadCommentsFromServer: function() {
|
||||
@@ -525,6 +526,9 @@ var CommentBox = React.createClass({
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
@@ -543,9 +547,7 @@ var CommentBox = React.createClass({
|
||||
<div className="commentBox">
|
||||
<h1>Comments</h1>
|
||||
<CommentList data={this.state.data} />
|
||||
<CommentForm
|
||||
onCommentSubmit={this.handleCommentSubmit}
|
||||
/>
|
||||
<CommentForm onCommentSubmit={this.handleCommentSubmit} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -569,11 +571,7 @@ var CommentForm = React.createClass({
|
||||
return (
|
||||
<form className="commentForm" onSubmit={this.handleSubmit}>
|
||||
<input type="text" placeholder="Your name" ref="author" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Say something..."
|
||||
ref="text"
|
||||
/>
|
||||
<input type="text" placeholder="Say something..." ref="text" />
|
||||
<input type="submit" value="Post" />
|
||||
</form>
|
||||
);
|
||||
@@ -583,7 +581,7 @@ var CommentForm = React.createClass({
|
||||
|
||||
Now that the callbacks are in place, all we have to do is submit to the server and refresh the list:
|
||||
|
||||
```javascript{13-21}
|
||||
```javascript{16-27}
|
||||
// tutorial19.js
|
||||
var CommentBox = React.createClass({
|
||||
loadCommentsFromServer: function() {
|
||||
@@ -592,6 +590,9 @@ var CommentBox = React.createClass({
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
@@ -603,6 +604,9 @@ var CommentBox = React.createClass({
|
||||
data: comment,
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
@@ -618,9 +622,7 @@ var CommentBox = React.createClass({
|
||||
<div className="commentBox">
|
||||
<h1>Comments</h1>
|
||||
<CommentList data={this.state.data} />
|
||||
<CommentForm
|
||||
onCommentSubmit={this.handleCommentSubmit}
|
||||
/>
|
||||
<CommentForm onCommentSubmit={this.handleCommentSubmit} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -631,7 +633,7 @@ var CommentBox = React.createClass({
|
||||
|
||||
Our application is now feature complete but it feels slow to have to wait for the request to complete before your comment appears in the list. We can optimistically add this comment to the list to make the app feel faster.
|
||||
|
||||
```javascript{13-15}
|
||||
```javascript{16-18}
|
||||
// tutorial20.js
|
||||
var CommentBox = React.createClass({
|
||||
loadCommentsFromServer: function() {
|
||||
@@ -640,6 +642,9 @@ var CommentBox = React.createClass({
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
@@ -654,6 +659,9 @@ var CommentBox = React.createClass({
|
||||
data: comment,
|
||||
success: function(data) {
|
||||
this.setState({data: data});
|
||||
}.bind(this),
|
||||
error: function(xhr, status, err) {
|
||||
console.error(this.props.url, status, err.toString());
|
||||
}.bind(this)
|
||||
});
|
||||
},
|
||||
@@ -669,9 +677,7 @@ var CommentBox = React.createClass({
|
||||
<div className="commentBox">
|
||||
<h1>Comments</h1>
|
||||
<CommentList data={this.state.data} />
|
||||
<CommentForm
|
||||
onCommentSubmit={this.handleCommentSubmit}
|
||||
/>
|
||||
<CommentForm onCommentSubmit={this.handleCommentSubmit} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ id: videos
|
||||
title: Videos
|
||||
layout: docs
|
||||
permalink: videos.html
|
||||
prev: tutorial.html
|
||||
prev: thinking-in-react.html
|
||||
next: complementary-tools.html
|
||||
---
|
||||
|
||||
@@ -13,6 +13,51 @@ next: complementary-tools.html
|
||||
|
||||
"At Facebook and Instagram, we’re trying to push the limits of what’s possible on the web with React. My talk will start with a brief introduction to the framework, and then dive into three controversial topics: Throwing out the notion of templates and building views with JavaScript, “re-rendering” your entire application when your data changes, and a lightweight implementation of the DOM and events." -- [Pete Hunt](http://www.petehunt.net/)
|
||||
|
||||
|
||||
### Thinking in react - tagtree.tv
|
||||
|
||||
A [tagtree.tv](http://tagtree.tv/) video conveying the principles of [Thinking in React](/react/docs/thinking-in-react.html) while building a simple app
|
||||
<figure>[](http://tagtree.tv/thinking-in-react)</figure>
|
||||
|
||||
|
||||
### Secrets of the Virtual DOM - MtnWest JS
|
||||
|
||||
<iframe width="560" height="315" src="//www.youtube.com/embed/h3KksH8gfcQ" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
"In this talk I’ll be discussing why we built a virtual DOM, how it compares to other systems, and its relevance to the future of browser technologies." -- [Pete Hunt](http://www.petehunt.net/)
|
||||
|
||||
### CodeWinds
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) talked with [Jeff Barczewski](http://jeff.barczewski.com/) about React in CodeWinds Episode 4.
|
||||
<figure>[](http://codewinds.com/4)</figure>
|
||||
|
||||
<table width="100%"><tr><td>
|
||||
02:08 - What is React and why use it?<br />
|
||||
03:08 - The symbiotic relationship of ClojureScript and React<br />
|
||||
04:54 - The history of React and why it was created<br />
|
||||
09:43 - Updating web page with React without using data binding<br />
|
||||
13:11 - Using the virtual DOM to change the browser DOM<br />
|
||||
13:57 - Programming with React, render targets HTML, canvas, other<br />
|
||||
16:45 - Working with designers. Contrasted with Ember and AngularJS<br />
|
||||
21:45 - JSX Compiler bridging HTML and React javascript<br />
|
||||
23:50 - Autobuilding JSX and in browser tools for React<br />
|
||||
24:50 - Tips and tricks to working with React, getting started<br />
|
||||
</td><td>
|
||||
27:17 - Rendering HTML on the server with Node.js. Rendering backends<br />
|
||||
29:20 - React evolved through survival of the fittest at Facebook<br />
|
||||
30:15 - Ideas for having state on server and client, using web sockets.<br />
|
||||
32:05 - React-multiuser - distributed shared mutable state using Firebase<br />
|
||||
33:03 - Better debugging with React using the state transitions, replaying events<br />
|
||||
34:08 - Differences from Web Components<br />
|
||||
34:25 - Notable companies using React<br />
|
||||
35:16 - Could a React backend plugin be created to target PDF?<br />
|
||||
36:30 - Future of React, what's next?<br />
|
||||
39:38 - Contributing and getting help<br />
|
||||
</td></tr></table>
|
||||
|
||||
[Read the episode notes](http://codewinds.com/4)
|
||||
|
||||
|
||||
### JavaScript Jabber
|
||||
|
||||
[Pete Hunt](http://www.petehunt.net/) and [Jordan Walke](https://github.com/jordwalke) talked about React in JavaScript Jabber 73.
|
||||
@@ -51,7 +96,7 @@ By [Tom Occhino](http://tomocchino.com/) and [Jordan Walke](https://github.com/j
|
||||
|
||||
By [Steven Luscher](https://github.com/steveluscher)
|
||||
|
||||
### Introduction to React - Joe Dev on Tech
|
||||
### Introduction to React - LAWebSpeed meetup
|
||||
|
||||
<iframe width="650" height="315" src="//www.youtube.com/embed/SMMRJif5QW0" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
@@ -65,4 +110,8 @@ by [Stoyan Stefanov](http://www.phpied.com/)
|
||||
|
||||
### "Functional DOM programming" - Meteor DevShop 11
|
||||
|
||||
<iframe width="650" height="315" src="//www.youtube.com/embed/Lqcs6hPOcFw?t=49m23s" frameborder="0" allowfullscreen></iframe>
|
||||
<iframe width="650" height="315" src="//www.youtube.com/embed/qqVbr_LaCIo" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
### "Rethinking Web App Development at Facebook" - Facebook F8 Conference 2014
|
||||
|
||||
<iframe width="650" height="315" src="//www.youtube.com/embed/nYkdrAPrdcw" frameborder="0" allowfullscreen></iframe>
|
||||
|
||||
@@ -57,15 +57,27 @@ The JSX transformer used to support [XML syntax](/react/docs/jsx-in-depth.html)
|
||||
|
||||
All scripts are also available via [CDNJS](http://cdnjs.com/libraries/react/).
|
||||
|
||||
## Bower
|
||||
## npm
|
||||
|
||||
```sh
|
||||
$ bower install --save react
|
||||
```
|
||||
|
||||
## NPM
|
||||
To install the JSX transformer on your computer, run:
|
||||
|
||||
```sh
|
||||
$ npm install -g react-tools
|
||||
```
|
||||
|
||||
For more info about the `jsx` binary, see the [Getting Started](/react/docs/getting-started.html#offline-transform) guide.
|
||||
|
||||
If you're using an npm-compatible packaging system like browserify or webpack, you can use the `react` package. After installing it using `npm install react` or adding `react` to `package.json`, you can use React:
|
||||
|
||||
```js
|
||||
var React = require('react');
|
||||
React.renderComponent(...);
|
||||
```
|
||||
|
||||
If you'd like to use any [add-ons](/react/docs/addons.html), use `var React = require('react/addons');` instead.
|
||||
|
||||
## Bower
|
||||
|
||||
```sh
|
||||
$ bower install --save react
|
||||
```
|
||||
|
||||
BIN
docs/downloads/react-0.10.0-rc1.zip
Normal file
BIN
docs/downloads/react-0.10.0-rc1.zip
Normal file
Binary file not shown.
BIN
docs/downloads/react-0.10.0.zip
Normal file
BIN
docs/downloads/react-0.10.0.zip
Normal file
Binary file not shown.
BIN
docs/downloads/react-0.11.0-rc1.zip
Normal file
BIN
docs/downloads/react-0.11.0-rc1.zip
Normal file
Binary file not shown.
BIN
docs/img/blog/makona-editor.png
Normal file
BIN
docs/img/blog/makona-editor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
BIN
docs/img/blog/react-svg-fbp.png
Normal file
BIN
docs/img/blog/react-svg-fbp.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
BIN
docs/img/docs/codewinds-004.png
Normal file
BIN
docs/img/docs/codewinds-004.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
BIN
docs/img/docs/thinking-in-react-tagtree.png
Normal file
BIN
docs/img/docs/thinking-in-react-tagtree.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
@@ -20,10 +20,17 @@ See [Inline Styles](/react/tips/inline-styles.html) for more info.
|
||||
|
||||
Sometimes you _do_ want to keep the CSS properties unitless. Here's a list of properties that won't get the automatic "px" suffix:
|
||||
|
||||
- `columnCount`
|
||||
- `fillOpacity`
|
||||
- `flex`
|
||||
- `flexGrow`
|
||||
- `flexShrink`
|
||||
- `fontWeight`
|
||||
- `lineClamp`
|
||||
- `lineHeight`
|
||||
- `opacity`
|
||||
- `order`
|
||||
- `orphans`
|
||||
- `widows`
|
||||
- `zIndex`
|
||||
- `zoom`
|
||||
|
||||
@@ -49,3 +49,5 @@ var GenericWrapper = React.createClass({
|
||||
|
||||
React.renderComponent(<GenericWrapper>hello</GenericWrapper>, mountNode);
|
||||
```
|
||||
|
||||
To make `this.props.children` easy to deal with, we've provided the [React.Children utilities](/react/docs/top-level-api.html#react.children).
|
||||
|
||||
@@ -20,5 +20,5 @@ React.renderComponent(<input value="hi" />, mountNode);
|
||||
|
||||
setTimeout(function() {
|
||||
React.renderComponent(<input value={null} />, mountNode);
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
@@ -26,7 +26,7 @@ var UserGist = React.createClass({
|
||||
$.get(this.props.source, function(result) {
|
||||
var lastGist = result[0];
|
||||
this.setState({
|
||||
username: lastGist.user.login,
|
||||
username: lastGist.owner.login,
|
||||
lastGistUrl: lastGist.html_url
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
5
examples/README.md
Normal file
5
examples/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# React Examples
|
||||
|
||||
Here are some small React demos. Some use [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html) and some include third-party library integration.
|
||||
|
||||
For more fully-featured examples, check out [React TodoMVC](http://todomvc.com/architecture-examples/react/) and [React + Backbone TodoMVC](http://todomvc.com/labs/architecture-examples/react-backbone/).
|
||||
@@ -18,9 +18,7 @@ var BallmerPeakCalculator = React.createClass({
|
||||
this.setState({bac: event.target.value});
|
||||
},
|
||||
render: function() {
|
||||
var bac;
|
||||
var pct;
|
||||
pct = computeBallmerPeak(this.state.bac);
|
||||
var pct = computeBallmerPeak(this.state.bac);
|
||||
if (isNaN(pct)) {
|
||||
pct = 'N/A';
|
||||
} else {
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
|
||||
<title>Ballmer Peak calculator</title>
|
||||
<title>Ballmer Peak Calculator</title>
|
||||
<link rel="stylesheet" href="../shared/css/base.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Ballmer Peak calculator</h1>
|
||||
<h1>Ballmer Peak Calculator</h1>
|
||||
<div id="container">
|
||||
<p>
|
||||
If you can see this, React is not working right. This is probably because you're viewing
|
||||
@@ -18,19 +18,9 @@
|
||||
</p>
|
||||
</div>
|
||||
<h4>Example Details</h4>
|
||||
<ul>
|
||||
<li>
|
||||
This is built with
|
||||
<a href="https://github.com/substack/node-browserify">browserify</a>.
|
||||
</li>
|
||||
<li>
|
||||
This is written with JSX in a separate file and transformed in the browser.
|
||||
</li>
|
||||
</ul>
|
||||
<p>This is written with JSX in a separate file and transformed in the browser.</p>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
Learn more at
|
||||
Learn more about React at
|
||||
<a href="http://facebook.github.io/react" target="_blank">facebook.github.io/react</a>.
|
||||
</p>
|
||||
<script src="../../build/react.js"></script>
|
||||
|
||||
@@ -2,68 +2,27 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
|
||||
<title>Basic Example with external JSX</title>
|
||||
<title>Basic Example with External JSX</title>
|
||||
<link rel="stylesheet" href="../shared/css/base.css" />
|
||||
<style type="text/css" media="screen">
|
||||
.codeBox {
|
||||
padding: 7px;
|
||||
overflow:scroll;
|
||||
background-color: #eee;
|
||||
font-weight:normal;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
window.setTimeout(function() {
|
||||
var chromeClientCLI = window.chromeClientCLI;
|
||||
var errorBox = window.errorBox;
|
||||
var chromeErrorFooter = window.chromeErrorFooter;
|
||||
var chromeInstructions = window.chromeInstructions;
|
||||
var isChrome = !!window.chrome;
|
||||
chromeClientCLI.innerText =
|
||||
'open -a "Google Chrome" --new \\\n' +
|
||||
' ' + window.location.href + ' \\\n' +
|
||||
' --args --allow-file-access-from-files --user-data-dir=/tmp';
|
||||
|
||||
errorBox.innerText =
|
||||
isChrome ? 'To run in Chrome, do one of the following:' :
|
||||
'Errors loading page: Check the console.'
|
||||
chromeErrorFooter.innerText =
|
||||
isChrome ? 'If page still does not load, check console.' : '';
|
||||
|
||||
if (!isChrome) {
|
||||
chromeInstructions.innerText = "";
|
||||
}
|
||||
}, 0);
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Basic Example with external JSX</h1>
|
||||
<h1>Basic Example with External JSX</h1>
|
||||
<div id="container">
|
||||
<p>
|
||||
<h4 id="errorBox" style="color: #733"></h4>
|
||||
<ol id="chromeInstructions">
|
||||
<li>
|
||||
Open this page on a Mac via the terminal command:
|
||||
<pre id="chromeClientCLI" class="codeBox">
|
||||
</li>
|
||||
<h4><i>OR</i></h4>
|
||||
<li>
|
||||
Serve this page from a web server
|
||||
<pre id="chromeServerCLI" class="codeBox">
|
||||
cd /Path/To/This/File
|
||||
python -m SimpleHTTPServer
|
||||
open -a "Google Chrome" <a href="http://localhost:8000/">http://localhost:8000/</a>. </pre>
|
||||
</li>
|
||||
</ol>
|
||||
<h4 id="chromeErrorFooter" style="color: #733"></h4>
|
||||
If you can see this, React is not working right. This is probably because you're viewing
|
||||
this on your file system instead of a web server. Try running
|
||||
<pre>
|
||||
python -m SimpleHTTPServer
|
||||
</pre>
|
||||
and going to <a href="http://localhost:8000/">http://localhost:8000/</a>.
|
||||
</p>
|
||||
</div>
|
||||
<h4>Example Details</h4>
|
||||
<p>This is written with JSX in a separate file and transformed in the browser.</p>
|
||||
<p>
|
||||
Example Details: This is built with
|
||||
<a href="https://github.com/substack/node-browserify">browserify</a>.
|
||||
A separate JSX file is transformed in the browser.
|
||||
Learn more about React at
|
||||
<a href="http://facebook.github.io/react" target="_blank">facebook.github.io/react</a>.
|
||||
</p>
|
||||
<script src="../../build/react.js"></script>
|
||||
<script src="../../build/JSXTransformer.js"></script>
|
||||
|
||||
@@ -2,42 +2,26 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='Content-type' content='text/html; charset=utf-8'>
|
||||
<title>Basic Example with precompiled JSX</title>
|
||||
<title>Basic Example with Precompiled JSX</title>
|
||||
<link rel="stylesheet" href="../shared/css/base.css" />
|
||||
</head>
|
||||
<body>
|
||||
<h1>Basic Example with precompiled JSX</h1>
|
||||
<h1>Basic Example with Precompiled JSX</h1>
|
||||
<div id="container">
|
||||
<p>
|
||||
To install React, follow the instructions on
|
||||
<a href="http://www.github.com/facebook/react/">GitHub</a>.
|
||||
</p>
|
||||
<p>
|
||||
If you can see this, React is not running. You probably didn't run:
|
||||
<pre>
|
||||
npm install -g react-tools
|
||||
jsx . build/
|
||||
</pre>
|
||||
If you can see this, React is not running. Try running:
|
||||
</p>
|
||||
<pre>npm install -g react-tools
|
||||
cd examples/basic-jsx-precompile/
|
||||
jsx . build/</pre>
|
||||
</div>
|
||||
<h4>Example Details</h4>
|
||||
<ul>
|
||||
<li>
|
||||
This is built with
|
||||
<a href="https://github.com/substack/node-browserify">browserify</a>.
|
||||
</li>
|
||||
<li>
|
||||
This is written with JSX and precompiled to vanilla JS by doing:
|
||||
<pre>
|
||||
npm install -g react-tools
|
||||
jsx . build/
|
||||
</pre>
|
||||
</li>
|
||||
</ul>
|
||||
<p>This is written with JSX in a separate file and precompiled to vanilla JS by running:</p>
|
||||
<pre>npm install -g react-tools
|
||||
cd examples/basic-jsx-precompile/
|
||||
jsx . build/</pre>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
Learn more at
|
||||
Learn more about React at
|
||||
<a href="http://facebook.github.io/react" target="_blank">facebook.github.io/react</a>.
|
||||
</p>
|
||||
<script src="../../build/react.js"></script>
|
||||
|
||||
@@ -18,19 +18,9 @@
|
||||
</p>
|
||||
</div>
|
||||
<h4>Example Details</h4>
|
||||
<ul>
|
||||
<li>
|
||||
This is built with
|
||||
<a href="https://github.com/substack/node-browserify">browserify</a>.
|
||||
</li>
|
||||
<li>
|
||||
This is written with JSX and transformed in the browser.
|
||||
</li>
|
||||
</ul>
|
||||
<p>This is written with JSX and transformed in the browser.<p>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
Learn more at
|
||||
Learn more about React at
|
||||
<a href="http://facebook.github.io/react" target="_blank">facebook.github.io/react</a>.
|
||||
</p>
|
||||
<script src="../../build/react.js"></script>
|
||||
|
||||
@@ -18,16 +18,9 @@
|
||||
</p>
|
||||
</div>
|
||||
<h4>Example Details</h4>
|
||||
<ul>
|
||||
<li>
|
||||
This is built with
|
||||
<a href="https://github.com/substack/node-browserify">browserify</a>.
|
||||
</li>
|
||||
</ul>
|
||||
<p>This is written in vanilla JavaScript (without JSX) and transformed in the browser.<p>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
Learn more at
|
||||
Learn more about React at
|
||||
<a href="http://facebook.github.io/react" target="_blank">facebook.github.io/react</a>.
|
||||
</p>
|
||||
<script src="../../build/react.js"></script>
|
||||
|
||||
6
examples/jquery-mobile/README.md
Normal file
6
examples/jquery-mobile/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
jQuery Mobile React Example
|
||||
===========================
|
||||
|
||||
This example demonstrates how jQuery Mobile applications can be built with React.
|
||||
|
||||
The source code is based on jQuery Mobile's [pages-multi-page example](https://github.com/jquery/jquery-mobile/tree/master/demos/pages-multi-page).
|
||||
18
examples/jquery-mobile/index.html
Normal file
18
examples/jquery-mobile/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>jQuery Mobile React Example</title>
|
||||
<link rel="stylesheet" href="//code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css" />
|
||||
<link rel="stylesheet" href="//demos.jquerymobile.com/1.4.0/_assets/css/jqm-demos.css" />
|
||||
</head>
|
||||
<body class="ui-mobile-viewport ui-overlay-a">
|
||||
<div id="content"></div>
|
||||
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
<script src="//code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script>
|
||||
<script src="../../build/react.js"></script>
|
||||
<script type="text/javascript" src="js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
178
examples/jquery-mobile/js/app.js
vendored
Normal file
178
examples/jquery-mobile/js/app.js
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* jQuery Mobile React Example
|
||||
*
|
||||
* Main application script.
|
||||
* For variety, this example is written in 100% JSHint-compliant JavaScript, not in JSX.
|
||||
*
|
||||
* Component structure:
|
||||
*
|
||||
* - App
|
||||
* |-- JQueryMobilePage (one)
|
||||
* | |-- JQueryMobileHeader
|
||||
* | |-- JQueryMobileContent
|
||||
* | | |-- PageOneContent
|
||||
* | | |-- JQueryMobileButton
|
||||
* | |-- JQueryMobileFooter
|
||||
* |-- JQueryMobilePage (two)
|
||||
* | |-- JQueryMobileHeader
|
||||
* | |-- JQueryMobileContent
|
||||
* | | |-- PageTwoContent
|
||||
* | | |-- JQueryMobileButton
|
||||
* | |-- JQueryMobileFooter
|
||||
* |-- JQueryMobilePage (popup)
|
||||
* |-- JQueryMobileHeader
|
||||
* |-- JQueryMobileContent
|
||||
* | |-- PagePopUpContent
|
||||
* | |-- JQueryMobileButton
|
||||
* |-- JQueryMobileFooter
|
||||
*/
|
||||
|
||||
/* global document, React */
|
||||
|
||||
'use strict';
|
||||
|
||||
/** Main application component. */
|
||||
var App = React.createClass({
|
||||
displayName: 'App',
|
||||
|
||||
render: function() {
|
||||
return React.DOM.div({className:'app'},
|
||||
JQueryMobilePage({id:'one'}, PageOneContent(null)),
|
||||
JQueryMobilePage({id:'two'}, PageTwoContent(null)),
|
||||
JQueryMobilePage({id:'popup', headerTheme:'b'}, PagePopUpContent(null))
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** jQuery Mobile button component. */
|
||||
var JQueryMobileButton = React.createClass({
|
||||
displayName: 'JQueryMobileButton',
|
||||
|
||||
getDefaultProps: function() {
|
||||
return {className:'ui-btn ui-shadow ui-corner-all'};
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return React.DOM.p(null,
|
||||
React.DOM.a(this.props, this.props.children)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** jQuery Mobile page content component. */
|
||||
var JQueryMobileContent = React.createClass({
|
||||
displayName: 'JQueryMobileContent',
|
||||
|
||||
render: function() {
|
||||
return React.DOM.div({role:'main', className:'ui-content'},
|
||||
this.props.children
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** jQuery Mobile footer component. */
|
||||
var JQueryMobileFooter = React.createClass({
|
||||
displayName: 'JQueryMobileFooter',
|
||||
|
||||
render: function() {
|
||||
return React.DOM.div({'data-role':'footer'},
|
||||
React.DOM.h4(null, 'Page footer')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** jQuery Mobile header component. */
|
||||
var JQueryMobileHeader = React.createClass({
|
||||
displayName: 'JQueryMobileHeader',
|
||||
|
||||
render: function() {
|
||||
return React.DOM.div({'data-role':'header', 'data-theme':this.props.headerTheme},
|
||||
React.DOM.h1(null, this.props.title)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** jQuery Mobile page component. */
|
||||
var JQueryMobilePage = React.createClass({
|
||||
displayName: 'JQueryMobilePage',
|
||||
|
||||
getDefaultProps: function() {
|
||||
return {'data-role':'page', 'data-theme':'a', headerTheme:'a'};
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return this.transferPropsTo(React.DOM.div(null,
|
||||
JQueryMobileHeader({title:'Page ' + this.props.id, headerTheme:this.props.headerTheme}),
|
||||
JQueryMobileContent(null, this.props.children),
|
||||
JQueryMobileFooter(null)
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
/** Application page one component. */
|
||||
var PageOneContent = React.createClass({
|
||||
displayName: 'PageOneContent',
|
||||
|
||||
render: function() {
|
||||
return React.DOM.div(null,
|
||||
React.DOM.h2(null, 'One'),
|
||||
React.DOM.p(null,
|
||||
'I have an ',
|
||||
React.DOM.code(null, 'id'),
|
||||
' of "one" on my page container. I\'m first in the source order so I\'m shown when the page loads.'
|
||||
),
|
||||
React.DOM.p(null, 'This is a multi-page boilerplate template that you can copy to build your first jQuery Mobile page. This template contains multiple "page" containers inside, unlike a single page template that has just one page within it.'),
|
||||
React.DOM.p(null, 'Just view the source and copy the code to get started. All the CSS and JS is linked to the jQuery CDN versions so this is super easy to set up. Remember to include a meta viewport tag in the head to set the zoom level.'),
|
||||
React.DOM.p(null,
|
||||
'You link to internal pages by referring to the ',
|
||||
React.DOM.code(null, 'id'),
|
||||
' of the page you want to show. For example, to ',
|
||||
React.DOM.a({href:'#two'}, 'link'),
|
||||
' to the page with an ',
|
||||
React.DOM.code(null, 'id'),
|
||||
' of "two", my link would have a ',
|
||||
React.DOM.code(null, 'href="#two"'),
|
||||
' in the code.'
|
||||
),
|
||||
React.DOM.h3(null, 'Show internal pages:'),
|
||||
JQueryMobileButton({href:'#two'}, 'Show page "two"'),
|
||||
JQueryMobileButton({href:'#popup', 'data-rel':'dialog', 'data-transition':'pop'}, 'Show page "popup" (as a dialog)')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** Application page two component. */
|
||||
var PageTwoContent = React.createClass({
|
||||
displayName: 'PageTwoContent',
|
||||
|
||||
render: function() {
|
||||
return React.DOM.div(null,
|
||||
React.DOM.h2(null, 'Two'),
|
||||
React.DOM.p(null, 'I have an id of "two" on my page container. I\'m the second page container in this multi-page template.'),
|
||||
React.DOM.p(null, 'Notice that the theme is different for this page because we\'ve added a few ',
|
||||
React.DOM.code(null, 'data-theme'),
|
||||
' swatch assigments here to show off how flexible it is. You can add any content or widget to these pages, but we\'re keeping these simple.'),
|
||||
JQueryMobileButton({href:'#one', 'data-direction':'reverse', className:'ui-btn ui-shadow ui-corner-all ui-btn-b'}, 'Back to page "one"')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/** Application popup page component. */
|
||||
var PagePopUpContent = React.createClass({
|
||||
displayName: 'PagePopUpContent',
|
||||
|
||||
render: function() {
|
||||
return React.DOM.div(null,
|
||||
React.DOM.h2(null, 'Popup'),
|
||||
React.DOM.p(null, 'I have an id of "popup" on my page container and only look like a dialog because the link to me had a ',
|
||||
React.DOM.code(null, 'data-rel="dialog"'),
|
||||
' attribute which gives me this inset look and a ',
|
||||
React.DOM.code(null, 'data-transition="pop"'),
|
||||
' attribute to change the transition to pop. Without this, I\'d be styled as a normal page.'),
|
||||
JQueryMobileButton({href:'#one', 'data-rel':'back', className:'ui-btn ui-shadow ui-corner-all ui-btn-inline ui-icon-back ui-btn-icon-left'}, 'Back to page "one"')
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Render application.
|
||||
React.renderComponent(App(null), document.getElementById('content'));
|
||||
@@ -1,3 +0,0 @@
|
||||
# TodoMVC-Backbone
|
||||
|
||||
This is a lightweight version of TodoMVC. Its primary purpose is to demo the Backbone integration rather than being feature-complete (refer to `todomvc-director` for a full TodoMVC-compilant app).
|
||||
@@ -1,556 +0,0 @@
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
font-size: 100%;
|
||||
vertical-align: baseline;
|
||||
font-family: inherit;
|
||||
color: inherit;
|
||||
-webkit-appearance: none;
|
||||
/*-moz-appearance: none;*/
|
||||
-ms-appearance: none;
|
||||
-o-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
body {
|
||||
font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
line-height: 1.4em;
|
||||
background: #eaeaea url('bg.png');
|
||||
color: #4d4d4d;
|
||||
width: 550px;
|
||||
margin: 0 auto;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-font-smoothing: antialiased;
|
||||
-ms-font-smoothing: antialiased;
|
||||
-o-font-smoothing: antialiased;
|
||||
font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
#todoapp {
|
||||
background: #fff;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
margin: 130px 0 40px 0;
|
||||
border: 1px solid #ccc;
|
||||
position: relative;
|
||||
border-top-left-radius: 2px;
|
||||
border-top-right-radius: 2px;
|
||||
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.2),
|
||||
0 25px 50px 0 rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
#todoapp:before {
|
||||
content: '';
|
||||
border-left: 1px solid #f5d6d6;
|
||||
border-right: 1px solid #f5d6d6;
|
||||
width: 2px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 40px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#todoapp input::-webkit-input-placeholder {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#todoapp input::-moz-placeholder {
|
||||
font-style: italic;
|
||||
color: #a9a9a9;
|
||||
}
|
||||
|
||||
#todoapp h1 {
|
||||
position: absolute;
|
||||
top: -120px;
|
||||
width: 100%;
|
||||
font-size: 70px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
color: #b3b3b3;
|
||||
color: rgba(255, 255, 255, 0.3);
|
||||
text-shadow: -1px -1px rgba(0, 0, 0, 0.2);
|
||||
-webkit-text-rendering: optimizeLegibility;
|
||||
-moz-text-rendering: optimizeLegibility;
|
||||
-ms-text-rendering: optimizeLegibility;
|
||||
-o-text-rendering: optimizeLegibility;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
#header {
|
||||
padding-top: 15px;
|
||||
border-radius: inherit;
|
||||
}
|
||||
|
||||
#header:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 15px;
|
||||
z-index: 2;
|
||||
border-bottom: 1px solid #6c615c;
|
||||
background: #8d7d77;
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(rgba(132, 110, 100, 0.8)),to(rgba(101, 84, 76, 0.8)));
|
||||
background: -webkit-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8));
|
||||
background: -moz-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8));
|
||||
background: -o-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8));
|
||||
background: -ms-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8));
|
||||
background: linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8));
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670');
|
||||
border-top-left-radius: 1px;
|
||||
border-top-right-radius: 1px;
|
||||
}
|
||||
|
||||
#new-todo,
|
||||
.edit {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
font-size: 24px;
|
||||
font-family: inherit;
|
||||
line-height: 1.4em;
|
||||
border: 0;
|
||||
outline: none;
|
||||
color: inherit;
|
||||
padding: 6px;
|
||||
border: 1px solid #999;
|
||||
box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2);
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-ms-box-sizing: border-box;
|
||||
-o-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-font-smoothing: antialiased;
|
||||
-ms-font-smoothing: antialiased;
|
||||
-o-font-smoothing: antialiased;
|
||||
font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
#new-todo {
|
||||
padding: 16px 16px 16px 60px;
|
||||
border: none;
|
||||
background: rgba(0, 0, 0, 0.02);
|
||||
z-index: 2;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#main {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
border-top: 1px dotted #adadad;
|
||||
}
|
||||
|
||||
label[for='toggle-all'] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#toggle-all {
|
||||
position: absolute;
|
||||
top: -42px;
|
||||
left: -4px;
|
||||
width: 40px;
|
||||
text-align: center;
|
||||
border: none; /* Mobile Safari */
|
||||
}
|
||||
|
||||
#toggle-all:before {
|
||||
content: '»';
|
||||
font-size: 28px;
|
||||
color: #d9d9d9;
|
||||
padding: 0 25px 7px;
|
||||
}
|
||||
|
||||
#toggle-all:checked:before {
|
||||
color: #737373;
|
||||
}
|
||||
|
||||
#todo-list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#todo-list li {
|
||||
position: relative;
|
||||
font-size: 24px;
|
||||
border-bottom: 1px dotted #ccc;
|
||||
}
|
||||
|
||||
#todo-list li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
#todo-list li.editing {
|
||||
border-bottom: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#todo-list li.editing .edit {
|
||||
display: block;
|
||||
width: 506px;
|
||||
padding: 13px 17px 12px 17px;
|
||||
margin: 0 0 0 43px;
|
||||
}
|
||||
|
||||
#todo-list li.editing .view {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#todo-list li .toggle {
|
||||
text-align: center;
|
||||
width: 40px;
|
||||
/* auto, since non-WebKit browsers doesn't support input styling */
|
||||
height: auto;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin: auto 0;
|
||||
border: none; /* Mobile Safari */
|
||||
-webkit-appearance: none;
|
||||
/*-moz-appearance: none;*/
|
||||
-ms-appearance: none;
|
||||
-o-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
#todo-list li .toggle:after {
|
||||
content: '✔';
|
||||
line-height: 43px; /* 40 + a couple of pixels visual adjustment */
|
||||
font-size: 20px;
|
||||
color: #d9d9d9;
|
||||
text-shadow: 0 -1px 0 #bfbfbf;
|
||||
}
|
||||
|
||||
#todo-list li .toggle:checked:after {
|
||||
color: #85ada7;
|
||||
text-shadow: 0 1px 0 #669991;
|
||||
bottom: 1px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#todo-list li label {
|
||||
white-space: pre;
|
||||
word-break: break-word;
|
||||
padding: 15px 60px 15px 15px;
|
||||
margin-left: 45px;
|
||||
display: block;
|
||||
line-height: 1.2;
|
||||
-webkit-transition: color 0.4s;
|
||||
-moz-transition: color 0.4s;
|
||||
-ms-transition: color 0.4s;
|
||||
-o-transition: color 0.4s;
|
||||
transition: color 0.4s;
|
||||
}
|
||||
|
||||
#todo-list li.completed label {
|
||||
color: #a9a9a9;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
#todo-list li .destroy {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
bottom: 0;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin: auto 0;
|
||||
font-size: 22px;
|
||||
color: #a88a8a;
|
||||
-webkit-transition: all 0.2s;
|
||||
-moz-transition: all 0.2s;
|
||||
-ms-transition: all 0.2s;
|
||||
-o-transition: all 0.2s;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
#todo-list li .destroy:hover {
|
||||
text-shadow: 0 0 1px #000,
|
||||
0 0 10px rgba(199, 107, 107, 0.8);
|
||||
-webkit-transform: scale(1.3);
|
||||
-moz-transform: scale(1.3);
|
||||
-ms-transform: scale(1.3);
|
||||
-o-transform: scale(1.3);
|
||||
transform: scale(1.3);
|
||||
}
|
||||
|
||||
#todo-list li .destroy:after {
|
||||
content: '✖';
|
||||
}
|
||||
|
||||
#todo-list li:hover .destroy {
|
||||
display: block;
|
||||
}
|
||||
|
||||
#todo-list li .edit {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#todo-list li.editing:last-child {
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
color: #777;
|
||||
padding: 0 15px;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: -31px;
|
||||
left: 0;
|
||||
height: 20px;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#footer:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 31px;
|
||||
left: 0;
|
||||
height: 50px;
|
||||
z-index: -1;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3),
|
||||
0 6px 0 -3px rgba(255, 255, 255, 0.8),
|
||||
0 7px 1px -3px rgba(0, 0, 0, 0.3),
|
||||
0 43px 0 -6px rgba(255, 255, 255, 0.8),
|
||||
0 44px 2px -6px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
#todo-count {
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#filters {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
#filters li {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#filters li a {
|
||||
color: #83756f;
|
||||
margin: 2px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#filters li a.selected {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#clear-completed {
|
||||
float: right;
|
||||
position: relative;
|
||||
line-height: 20px;
|
||||
text-decoration: none;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
font-size: 11px;
|
||||
padding: 0 10px;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
#clear-completed:hover {
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
box-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
#info {
|
||||
margin: 65px auto 0;
|
||||
color: #a6a6a6;
|
||||
font-size: 12px;
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#info a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/*
|
||||
Hack to remove background from Mobile Safari.
|
||||
Can't use it globally since it destroys checkboxes in Firefox and Opera
|
||||
*/
|
||||
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
||||
#toggle-all,
|
||||
#todo-list li .toggle {
|
||||
background: none;
|
||||
}
|
||||
|
||||
#todo-list li .toggle {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
#toggle-all {
|
||||
top: -56px;
|
||||
left: -15px;
|
||||
width: 65px;
|
||||
height: 41px;
|
||||
-webkit-transform: rotate(90deg);
|
||||
transform: rotate(90deg);
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 20px 0;
|
||||
border: 0;
|
||||
border-top: 1px dashed #C5C5C5;
|
||||
border-bottom: 1px dashed #F7F7F7;
|
||||
}
|
||||
|
||||
.learn a {
|
||||
font-weight: normal;
|
||||
text-decoration: none;
|
||||
color: #b83f45;
|
||||
}
|
||||
|
||||
.learn a:hover {
|
||||
text-decoration: underline;
|
||||
color: #787e7e;
|
||||
}
|
||||
|
||||
.learn h3,
|
||||
.learn h4,
|
||||
.learn h5 {
|
||||
margin: 10px 0;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.learn h3 {
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.learn h4 {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.learn h5 {
|
||||
margin-bottom: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.learn ul {
|
||||
padding: 0;
|
||||
margin: 0 0 30px 25px;
|
||||
}
|
||||
|
||||
.learn li {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.learn p {
|
||||
font-size: 15px;
|
||||
font-weight: 300;
|
||||
line-height: 1.3;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.quote {
|
||||
border: none;
|
||||
margin: 20px 0 60px 0;
|
||||
}
|
||||
|
||||
.quote p {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.quote p:before {
|
||||
content: '“';
|
||||
font-size: 50px;
|
||||
opacity: .15;
|
||||
position: absolute;
|
||||
top: -20px;
|
||||
left: 3px;
|
||||
}
|
||||
|
||||
.quote p:after {
|
||||
content: '”';
|
||||
font-size: 50px;
|
||||
opacity: .15;
|
||||
position: absolute;
|
||||
bottom: -42px;
|
||||
right: 3px;
|
||||
}
|
||||
|
||||
.quote footer {
|
||||
position: absolute;
|
||||
bottom: -40px;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.quote footer img {
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.quote footer a {
|
||||
margin-left: 5px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.speech-bubble {
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
background: rgba(0, 0, 0, .04);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.speech-bubble:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 30px;
|
||||
border: 13px solid transparent;
|
||||
border-top-color: rgba(0, 0, 0, .04);
|
||||
}
|
||||
|
||||
/**body*/.learn-bar > .learn {
|
||||
position: absolute;
|
||||
width: 272px;
|
||||
top: 8px;
|
||||
left: -300px;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
background-color: rgba(255, 255, 255, .6);
|
||||
transition-property: left;
|
||||
transition-duration: 500ms;
|
||||
}
|
||||
|
||||
@media (min-width: 899px) {
|
||||
/**body*/.learn-bar {
|
||||
width: auto;
|
||||
margin: 0 0 0 300px;
|
||||
}
|
||||
/**body*/.learn-bar > .learn {
|
||||
left: 8px;
|
||||
}
|
||||
/**body*/.learn-bar #todoapp {
|
||||
width: 550px;
|
||||
margin: 130px auto 40px auto;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB |
@@ -1,22 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>React • TodoMVC</title>
|
||||
<link rel="stylesheet" href="css/base.css">
|
||||
<!--[if IE]>
|
||||
<script src="js/ie.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script src="../../build/react.js"></script>
|
||||
<script src="../../build/JSXTransformer.js"></script>
|
||||
<script type="text/javascript" src="../shared/thirdparty/jquery.min.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="thirdparty/lodash.min.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="thirdparty/backbone-min.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="thirdparty/backbone.localStorage-min.js" charset="utf-8"></script>
|
||||
<script type="text/jsx" src="js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,303 +0,0 @@
|
||||
/** @jsx React.DOM */
|
||||
|
||||
var Todo = Backbone.Model.extend({
|
||||
// Default attributes for the todo
|
||||
// and ensure that each todo created has `title` and `completed` keys.
|
||||
defaults: {
|
||||
title: '',
|
||||
completed: false
|
||||
},
|
||||
|
||||
// Toggle the `completed` state of this todo item.
|
||||
toggle: function() {
|
||||
this.save({
|
||||
completed: !this.get('completed')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var TodoList = Backbone.Collection.extend({
|
||||
|
||||
// Reference to this collection's model.
|
||||
model: Todo,
|
||||
|
||||
// Save all of the todo items under the `"todos"` namespace.
|
||||
localStorage: new Store('todos-react-backbone'),
|
||||
|
||||
// Filter down the list of all todo items that are finished.
|
||||
completed: function() {
|
||||
return this.filter(function( todo ) {
|
||||
return todo.get('completed');
|
||||
});
|
||||
},
|
||||
|
||||
remaining: function() {
|
||||
return this.without.apply(this, this.completed());
|
||||
},
|
||||
|
||||
// We keep the Todos in sequential order, despite being saved by unordered
|
||||
// GUID in the database. This generates the next order number for new items.
|
||||
nextOrder: function () {
|
||||
if (!this.length) {
|
||||
return 1;
|
||||
}
|
||||
return this.last().get('order') + 1;
|
||||
},
|
||||
|
||||
// Todos are sorted by their original insertion order.
|
||||
comparator: function (todo) {
|
||||
return todo.get('order');
|
||||
}
|
||||
});
|
||||
|
||||
var Utils = {
|
||||
pluralize: function( count, word ) {
|
||||
return count === 1 ? word : word + 's';
|
||||
},
|
||||
|
||||
stringifyObjKeys: function(obj) {
|
||||
var s = '';
|
||||
for (var key in obj) {
|
||||
if (!obj.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
if (obj[key]) {
|
||||
s += key + ' ';
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
};
|
||||
|
||||
// Begin React stuff
|
||||
|
||||
var TodoItem = React.createClass({
|
||||
handleSubmit: function(event) {
|
||||
var val = this.refs.editField.getDOMNode().value.trim();
|
||||
if (val) {
|
||||
this.props.onSave(val);
|
||||
} else {
|
||||
this.props.onDestroy();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
onEdit: function() {
|
||||
this.props.onEdit();
|
||||
this.refs.editField.getDOMNode().focus();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var classes = Utils.stringifyObjKeys({
|
||||
completed: this.props.todo.get('completed'), editing: this.props.editing
|
||||
});
|
||||
return (
|
||||
<li className={classes}>
|
||||
<div className="view">
|
||||
<input
|
||||
className="toggle"
|
||||
type="checkbox"
|
||||
checked={this.props.todo.get('completed')}
|
||||
onChange={this.props.onToggle}
|
||||
key={this.props.key}
|
||||
/>
|
||||
<label onDoubleClick={this.onEdit}>
|
||||
{this.props.todo.get('title')}
|
||||
</label>
|
||||
<button className="destroy" onClick={this.props.onDestroy} />
|
||||
</div>
|
||||
<form onSubmit={this.handleSubmit}>
|
||||
<input
|
||||
ref="editField"
|
||||
className="edit"
|
||||
defaultValue={this.props.todo.get('title')}
|
||||
onBlur={this.handleSubmit}
|
||||
autoFocus="autofocus"
|
||||
/>
|
||||
</form>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var TodoFooter = React.createClass({
|
||||
render: function() {
|
||||
var activeTodoWord = Utils.pluralize(this.props.count, 'todo');
|
||||
var clearButton = null;
|
||||
|
||||
if (this.props.completedCount > 0) {
|
||||
clearButton = (
|
||||
<button id="clear-completed" onClick={this.props.onClearCompleted}>
|
||||
Clear completed ({this.props.completedCount})
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<footer id="footer">
|
||||
<span id="todo-count">
|
||||
<strong>{this.props.count}</strong>{' '}
|
||||
{activeTodoWord}{' '}left
|
||||
</span>
|
||||
{clearButton}
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// An example generic Mixin that you can add to any component that should react
|
||||
// to changes in a Backbone component. The use cases we've identified thus far
|
||||
// are for Collections -- since they trigger a change event whenever any of
|
||||
// their constituent items are changed there's no need to reconcile for regular
|
||||
// models. One caveat: this relies on getBackboneModels() to always return the
|
||||
// same model instances throughout the lifecycle of the component. If you're
|
||||
// using this mixin correctly (it should be near the top of your component
|
||||
// hierarchy) this should not be an issue.
|
||||
var BackboneMixin = {
|
||||
componentDidMount: function() {
|
||||
// Whenever there may be a change in the Backbone data, trigger a reconcile.
|
||||
this.getBackboneModels().forEach(function(model) {
|
||||
model.on('add change remove', this.forceUpdate.bind(this, null), this);
|
||||
}, this);
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
// Ensure that we clean up any dangling references when the component is
|
||||
// destroyed.
|
||||
this.getBackboneModels().forEach(function(model) {
|
||||
model.off(null, null, this);
|
||||
}, this);
|
||||
}
|
||||
};
|
||||
|
||||
var TodoApp = React.createClass({
|
||||
mixins: [BackboneMixin],
|
||||
getInitialState: function() {
|
||||
return {editing: null};
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
// Additional functionality for todomvc: fetch() the collection on init
|
||||
this.props.todos.fetch();
|
||||
this.refs.newField.getDOMNode().focus();
|
||||
},
|
||||
|
||||
componentDidUpdate: function() {
|
||||
// If saving were expensive we'd listen for mutation events on Backbone and
|
||||
// do this manually. however, since saving isn't expensive this is an
|
||||
// elegant way to keep it reactively up-to-date.
|
||||
this.props.todos.forEach(function(todo) {
|
||||
todo.save();
|
||||
});
|
||||
},
|
||||
|
||||
getBackboneModels: function() {
|
||||
return [this.props.todos];
|
||||
},
|
||||
|
||||
handleSubmit: function(event) {
|
||||
event.preventDefault();
|
||||
var val = this.refs.newField.getDOMNode().value.trim();
|
||||
if (val) {
|
||||
this.props.todos.create({
|
||||
title: val,
|
||||
completed: false,
|
||||
order: this.props.todos.nextOrder()
|
||||
});
|
||||
this.refs.newField.getDOMNode().value = '';
|
||||
}
|
||||
},
|
||||
|
||||
toggleAll: function(event) {
|
||||
var checked = event.nativeEvent.target.checked;
|
||||
this.props.todos.forEach(function(todo) {
|
||||
todo.set('completed', checked);
|
||||
});
|
||||
},
|
||||
|
||||
edit: function(todo) {
|
||||
this.setState({editing: todo.get('id')});
|
||||
},
|
||||
|
||||
save: function(todo, text) {
|
||||
todo.set('title', text);
|
||||
this.setState({editing: null});
|
||||
},
|
||||
|
||||
clearCompleted: function() {
|
||||
this.props.todos.completed().forEach(function(todo) {
|
||||
todo.destroy();
|
||||
});
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var footer = null;
|
||||
var main = null;
|
||||
var todoItems = this.props.todos.map(function(todo) {
|
||||
return (
|
||||
<TodoItem
|
||||
key={Math.random()}
|
||||
todo={todo}
|
||||
onToggle={todo.toggle.bind(todo)}
|
||||
onDestroy={todo.destroy.bind(todo)}
|
||||
onEdit={this.edit.bind(this, todo)}
|
||||
editing={this.state.editing === todo.get('id')}
|
||||
onSave={this.save.bind(this, todo)}
|
||||
/>
|
||||
);
|
||||
}, this);
|
||||
|
||||
var activeTodoCount = this.props.todos.remaining().length;
|
||||
var completedCount = todoItems.length - activeTodoCount;
|
||||
if (activeTodoCount || completedCount) {
|
||||
footer =
|
||||
<TodoFooter
|
||||
count={activeTodoCount}
|
||||
completedCount={completedCount}
|
||||
onClearCompleted={this.clearCompleted}
|
||||
/>;
|
||||
}
|
||||
|
||||
if (todoItems.length) {
|
||||
main = (
|
||||
<section id="main">
|
||||
<input id="toggle-all" type="checkbox" onChange={this.toggleAll} />
|
||||
<ul id="todo-list">
|
||||
{todoItems}
|
||||
</ul>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<section id="todoapp">
|
||||
<header id="header">
|
||||
<h1>todos</h1>
|
||||
<form onSubmit={this.handleSubmit}>
|
||||
<input
|
||||
ref="newField"
|
||||
id="new-todo"
|
||||
placeholder="What needs to be done?"
|
||||
/>
|
||||
</form>
|
||||
</header>
|
||||
{main}
|
||||
{footer}
|
||||
</section>
|
||||
<footer id="info">
|
||||
<p>Double-click to edit a todo</p>
|
||||
<p>
|
||||
Created by{' '}
|
||||
<a href="http://github.com/petehunt/">petehunt</a>
|
||||
</p>
|
||||
<p>Part of{' '}<a href="http://todomvc.com">TodoMVC</a></p>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
React.renderComponent(
|
||||
<TodoApp todos={new TodoList()} />, document.getElementById('container')
|
||||
);
|
||||
@@ -1,34 +0,0 @@
|
||||
/*! HTML5 Shiv pre3.6 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
||||
Uncompressed source: https://github.com/aFarkas/html5shiv */
|
||||
(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,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 mark meter nav output progress section summary time video",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);
|
||||
|
||||
/* ES5-shim
|
||||
https://github.com/kriskowal/es5-shim
|
||||
Copyright 2009-2012 by contributors, MIT License */
|
||||
(function(definition){if(typeof define=="function")define(definition);else if(typeof YUI=="function")YUI.add("es5",definition);else definition()})(function(){if(!Function.prototype.bind)Function.prototype.bind=function bind(that){var target=this;if(typeof target!="function")throw new TypeError("Function.prototype.bind called on incompatible "+target);var args=slice.call(arguments,1);var bound=function(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));if(Object(result)===
|
||||
result)return result;return this}else return target.apply(that,args.concat(slice.call(arguments)))};if(target.prototype)bound.prototype=Object.create(target.prototype);return bound};var call=Function.prototype.call;var prototypeOfArray=Array.prototype;var prototypeOfObject=Object.prototype;var slice=prototypeOfArray.slice;var _toString=call.bind(prototypeOfObject.toString);var owns=call.bind(prototypeOfObject.hasOwnProperty);var defineGetter;var defineSetter;var lookupGetter;var lookupSetter;var supportsAccessors;
|
||||
if(supportsAccessors=owns(prototypeOfObject,"__defineGetter__")){defineGetter=call.bind(prototypeOfObject.__defineGetter__);defineSetter=call.bind(prototypeOfObject.__defineSetter__);lookupGetter=call.bind(prototypeOfObject.__lookupGetter__);lookupSetter=call.bind(prototypeOfObject.__lookupSetter__)}if([1,2].splice(0).length!=2){var array_splice=Array.prototype.splice;Array.prototype.splice=function(start,deleteCount){if(!arguments.length)return[];else return array_splice.apply(this,[start===void 0?
|
||||
0:start,deleteCount===void 0?this.length-start:deleteCount].concat(slice.call(arguments,2)))}}if(!Array.isArray)Array.isArray=function isArray(obj){return _toString(obj)=="[object Array]"};var boxedString=Object("a"),splitString=boxedString[0]!="a"||!(0 in boxedString);if(!Array.prototype.forEach)Array.prototype.forEach=function forEach(fun){var object=toObject(this),self=splitString&&_toString(this)=="[object String]"?this.split(""):object,thisp=arguments[1],i=-1,length=self.length>>>0;if(_toString(fun)!=
|
||||
"[object Function]")throw new TypeError;while(++i<length)if(i in self)fun.call(thisp,self[i],i,object)};if(!Array.prototype.map)Array.prototype.map=function map(fun){var object=toObject(this),self=splitString&&_toString(this)=="[object String]"?this.split(""):object,length=self.length>>>0,result=Array(length),thisp=arguments[1];if(_toString(fun)!="[object Function]")throw new TypeError(fun+" is not a function");for(var i=0;i<length;i++)if(i in self)result[i]=fun.call(thisp,self[i],i,object);return result};
|
||||
if(!Array.prototype.filter)Array.prototype.filter=function filter(fun){var object=toObject(this),self=splitString&&_toString(this)=="[object String]"?this.split(""):object,length=self.length>>>0,result=[],value,thisp=arguments[1];if(_toString(fun)!="[object Function]")throw new TypeError(fun+" is not a function");for(var i=0;i<length;i++)if(i in self){value=self[i];if(fun.call(thisp,value,i,object))result.push(value)}return result};if(!Array.prototype.every)Array.prototype.every=function every(fun){var object=
|
||||
toObject(this),self=splitString&&_toString(this)=="[object String]"?this.split(""):object,length=self.length>>>0,thisp=arguments[1];if(_toString(fun)!="[object Function]")throw new TypeError(fun+" is not a function");for(var i=0;i<length;i++)if(i in self&&!fun.call(thisp,self[i],i,object))return false;return true};if(!Array.prototype.some)Array.prototype.some=function some(fun){var object=toObject(this),self=splitString&&_toString(this)=="[object String]"?this.split(""):object,length=self.length>>>
|
||||
0,thisp=arguments[1];if(_toString(fun)!="[object Function]")throw new TypeError(fun+" is not a function");for(var i=0;i<length;i++)if(i in self&&fun.call(thisp,self[i],i,object))return true;return false};if(!Array.prototype.reduce)Array.prototype.reduce=function reduce(fun){var object=toObject(this),self=splitString&&_toString(this)=="[object String]"?this.split(""):object,length=self.length>>>0;if(_toString(fun)!="[object Function]")throw new TypeError(fun+" is not a function");if(!length&&arguments.length==
|
||||
1)throw new TypeError("reduce of empty array with no initial value");var i=0;var result;if(arguments.length>=2)result=arguments[1];else{do{if(i in self){result=self[i++];break}if(++i>=length)throw new TypeError("reduce of empty array with no initial value");}while(true)}for(;i<length;i++)if(i in self)result=fun.call(void 0,result,self[i],i,object);return result};if(!Array.prototype.reduceRight)Array.prototype.reduceRight=function reduceRight(fun){var object=toObject(this),self=splitString&&_toString(this)==
|
||||
"[object String]"?this.split(""):object,length=self.length>>>0;if(_toString(fun)!="[object Function]")throw new TypeError(fun+" is not a function");if(!length&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");var result,i=length-1;if(arguments.length>=2)result=arguments[1];else{do{if(i in self){result=self[i--];break}if(--i<0)throw new TypeError("reduceRight of empty array with no initial value");}while(true)}do if(i in this)result=fun.call(void 0,result,
|
||||
self[i],i,object);while(i--);return result};if(!Array.prototype.indexOf||[0,1].indexOf(1,2)!=-1)Array.prototype.indexOf=function indexOf(sought){var self=splitString&&_toString(this)=="[object String]"?this.split(""):toObject(this),length=self.length>>>0;if(!length)return-1;var i=0;if(arguments.length>1)i=toInteger(arguments[1]);i=i>=0?i:Math.max(0,length+i);for(;i<length;i++)if(i in self&&self[i]===sought)return i;return-1};if(!Array.prototype.lastIndexOf||[0,1].lastIndexOf(0,-3)!=-1)Array.prototype.lastIndexOf=
|
||||
function lastIndexOf(sought){var self=splitString&&_toString(this)=="[object String]"?this.split(""):toObject(this),length=self.length>>>0;if(!length)return-1;var i=length-1;if(arguments.length>1)i=Math.min(i,toInteger(arguments[1]));i=i>=0?i:length-Math.abs(i);for(;i>=0;i--)if(i in self&&sought===self[i])return i;return-1};if(!Object.keys){var hasDontEnumBug=true,dontEnums=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],dontEnumsLength=
|
||||
dontEnums.length;for(var key in{"toString":null})hasDontEnumBug=false;Object.keys=function keys(object){if(typeof object!="object"&&typeof object!="function"||object===null)throw new TypeError("Object.keys called on a non-object");var keys=[];for(var name in object)if(owns(object,name))keys.push(name);if(hasDontEnumBug)for(var i=0,ii=dontEnumsLength;i<ii;i++){var dontEnum=dontEnums[i];if(owns(object,dontEnum))keys.push(dontEnum)}return keys}}var negativeDate=-621987552E5,negativeYearString="-000001";
|
||||
if(!Date.prototype.toISOString||(new Date(negativeDate)).toISOString().indexOf(negativeYearString)===-1)Date.prototype.toISOString=function toISOString(){var result,length,value,year,month;if(!isFinite(this))throw new RangeError("Date.prototype.toISOString called on non-finite value.");year=this.getUTCFullYear();month=this.getUTCMonth();year+=Math.floor(month/12);month=(month%12+12)%12;result=[month+1,this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds()];year=(year<0?"-":
|
||||
year>9999?"+":"")+("00000"+Math.abs(year)).slice(0<=year&&year<=9999?-4:-6);length=result.length;while(length--){value=result[length];if(value<10)result[length]="0"+value}return year+"-"+result.slice(0,2).join("-")+"T"+result.slice(2).join(":")+"."+("000"+this.getUTCMilliseconds()).slice(-3)+"Z"};var dateToJSONIsSupported=false;try{dateToJSONIsSupported=Date.prototype.toJSON&&(new Date(NaN)).toJSON()===null&&(new Date(negativeDate)).toJSON().indexOf(negativeYearString)!==-1&&Date.prototype.toJSON.call({toISOString:function(){return true}})}catch(e){}if(!dateToJSONIsSupported)Date.prototype.toJSON=
|
||||
function toJSON(key){var o=Object(this),tv=toPrimitive(o),toISO;if(typeof tv==="number"&&!isFinite(tv))return null;toISO=o.toISOString;if(typeof toISO!="function")throw new TypeError("toISOString property is not callable");return toISO.call(o)};if(!Date.parse||"Date.parse is buggy")Date=function(NativeDate){function Date(Y,M,D,h,m,s,ms){var length=arguments.length;if(this instanceof NativeDate){var date=length==1&&String(Y)===Y?new NativeDate(Date.parse(Y)):length>=7?new NativeDate(Y,M,D,h,m,s,ms):
|
||||
length>=6?new NativeDate(Y,M,D,h,m,s):length>=5?new NativeDate(Y,M,D,h,m):length>=4?new NativeDate(Y,M,D,h):length>=3?new NativeDate(Y,M,D):length>=2?new NativeDate(Y,M):length>=1?new NativeDate(Y):new NativeDate;date.constructor=Date;return date}return NativeDate.apply(this,arguments)}var isoDateExpression=new RegExp("^"+"(\\d{4}|[+-]\\d{6})"+"(?:-(\\d{2})"+"(?:-(\\d{2})"+"(?:"+"T(\\d{2})"+":(\\d{2})"+"(?:"+":(\\d{2})"+"(?:\\.(\\d{3}))?"+")?"+"("+"Z|"+"(?:"+"([-+])"+"(\\d{2})"+":(\\d{2})"+")"+")?)?)?)?"+
|
||||
"$");var months=[0,31,59,90,120,151,181,212,243,273,304,334,365];function dayFromMonth(year,month){var t=month>1?1:0;return months[month]+Math.floor((year-1969+t)/4)-Math.floor((year-1901+t)/100)+Math.floor((year-1601+t)/400)+365*(year-1970)}for(var key in NativeDate)Date[key]=NativeDate[key];Date.now=NativeDate.now;Date.UTC=NativeDate.UTC;Date.prototype=NativeDate.prototype;Date.prototype.constructor=Date;Date.parse=function parse(string){var match=isoDateExpression.exec(string);if(match){var year=
|
||||
Number(match[1]),month=Number(match[2]||1)-1,day=Number(match[3]||1)-1,hour=Number(match[4]||0),minute=Number(match[5]||0),second=Number(match[6]||0),millisecond=Number(match[7]||0),offset=!match[4]||match[8]?0:Number(new NativeDate(1970,0)),signOffset=match[9]==="-"?1:-1,hourOffset=Number(match[10]||0),minuteOffset=Number(match[11]||0),result;if(hour<(minute>0||second>0||millisecond>0?24:25)&&minute<60&&second<60&&millisecond<1E3&&month>-1&&month<12&&hourOffset<24&&minuteOffset<60&&day>-1&&day<dayFromMonth(year,
|
||||
month+1)-dayFromMonth(year,month)){result=((dayFromMonth(year,month)+day)*24+hour+hourOffset*signOffset)*60;result=((result+minute+minuteOffset*signOffset)*60+second)*1E3+millisecond+offset;if(-864E13<=result&&result<=864E13)return result}return NaN}return NativeDate.parse.apply(this,arguments)};return Date}(Date);if(!Date.now)Date.now=function now(){return(new Date).getTime()};if("0".split(void 0,0).length){var string_split=String.prototype.split;String.prototype.split=function(separator,limit){if(separator===
|
||||
void 0&&limit===0)return[];return string_split.apply(this,arguments)}}if("".substr&&"0b".substr(-1)!=="b"){var string_substr=String.prototype.substr;String.prototype.substr=function(start,length){return string_substr.call(this,start<0?(start=this.length+start)<0?0:start:start,length)}}var ws="\t\n\x0B\f\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003"+"\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028"+"\u2029\ufeff";if(!String.prototype.trim||ws.trim()){ws="["+ws+"]";var trimBeginRegexp=
|
||||
new RegExp("^"+ws+ws+"*"),trimEndRegexp=new RegExp(ws+ws+"*$");String.prototype.trim=function trim(){if(this===undefined||this===null)throw new TypeError("can't convert "+this+" to object");return String(this).replace(trimBeginRegexp,"").replace(trimEndRegexp,"")}}function toInteger(n){n=+n;if(n!==n)n=0;else if(n!==0&&n!==1/0&&n!==-(1/0))n=(n>0||-1)*Math.floor(Math.abs(n));return n}function isPrimitive(input){var type=typeof input;return input===null||type==="undefined"||type==="boolean"||type===
|
||||
"number"||type==="string"}function toPrimitive(input){var val,valueOf,toString;if(isPrimitive(input))return input;valueOf=input.valueOf;if(typeof valueOf==="function"){val=valueOf.call(input);if(isPrimitive(val))return val}toString=input.toString;if(typeof toString==="function"){val=toString.call(input);if(isPrimitive(val))return val}throw new TypeError;}var toObject=function(o){if(o==null)throw new TypeError("can't convert "+o+" to object");return Object(o)}});
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* Backbone localStorage Adapter
|
||||
* Version 1.1.4
|
||||
*
|
||||
* https://github.com/jeromegn/Backbone.localStorage
|
||||
*/(function(a,b){typeof exports=="object"?module.exports=b(require("underscore"),require("backbone")):typeof define=="function"&&define.amd?define(["underscore","backbone"],function(c,d){return b(c||a._,d||a.Backbone)}):b(_,Backbone)})(this,function(a,b){function c(){return((1+Math.random())*65536|0).toString(16).substring(1)}function d(){return c()+c()+"-"+c()+"-"+c()+"-"+c()+"-"+c()+c()+c()}return b.LocalStorage=window.Store=function(a){if(!this.localStorage)throw"Backbone.localStorage: Environment does not support localStorage.";this.name=a;var b=this.localStorage().getItem(this.name);this.records=b&&b.split(",")||[]},a.extend(b.LocalStorage.prototype,{save:function(){this.localStorage().setItem(this.name,this.records.join(","))},create:function(a){return a.id||(a.id=d(),a.set(a.idAttribute,a.id)),this.localStorage().setItem(this.name+"-"+a.id,JSON.stringify(a)),this.records.push(a.id.toString()),this.save(),this.find(a)},update:function(b){return this.localStorage().setItem(this.name+"-"+b.id,JSON.stringify(b)),a.include(this.records,b.id.toString())||this.records.push(b.id.toString()),this.save(),this.find(b)},find:function(a){return this.jsonData(this.localStorage().getItem(this.name+"-"+a.id))},findAll:function(){return(a.chain||a)(this.records).map(function(a){return this.jsonData(this.localStorage().getItem(this.name+"-"+a))},this).compact().value()},destroy:function(b){return b.isNew()?!1:(this.localStorage().removeItem(this.name+"-"+b.id),this.records=a.reject(this.records,function(a){return a===b.id.toString()}),this.save(),b)},localStorage:function(){return localStorage},jsonData:function(a){return a&&JSON.parse(a)},_clear:function(){var b=this.localStorage(),c=new RegExp("^"+this.name+"-");b.removeItem(this.name),(a.chain||a)(b).keys().filter(function(a){return c.test(a)}).each(function(a){b.removeItem(a)})},_storageSize:function(){return this.localStorage().length}}),b.LocalStorage.sync=window.Store.sync=b.localSync=function(a,c,d){var e=c.localStorage||c.collection.localStorage,f,g,h=b.$.Deferred&&b.$.Deferred();try{switch(a){case"read":f=c.id!=undefined?e.find(c):e.findAll();break;case"create":f=e.create(c);break;case"update":f=e.update(c);break;case"delete":f=e.destroy(c)}}catch(i){i.code===DOMException.QUOTA_EXCEEDED_ERR&&e._storageSize()===0?g="Private browsing is unsupported":g=i.message}return f?(d&&d.success&&(b.VERSION==="0.9.10"?d.success(c,f,d):d.success(f)),h&&h.resolve(f)):(g=g?g:"Record Not Found",d&&d.error&&(b.VERSION==="0.9.10"?d.error(c,g,d):d.error(g)),h&&h.reject(g)),d&&d.complete&&d.complete(f),h&&h.promise()},b.ajaxSync=b.sync,b.getSyncMethod=function(a){return a.localStorage||a.collection&&a.collection.localStorage?b.localSync:b.ajaxSync},b.sync=function(a,c,d){return b.getSyncMethod(c).apply(this,[a,c,d])},b.LocalStorage});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user