|
1 |
| -# Advance React Patterns v2 |
2 |
| - |
3 |
| -### Patterns 🔥🔥🔥🔥🔥 |
4 |
| - 1. [Compound Component](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F02.js) |
5 |
| - 2. [Flexible Compound Components with context](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F03.js) |
6 |
| - 3. [render props](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F04.js) |
7 |
| - 4. [prop collections](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F05.js) |
8 |
| - 5. [Prop getters](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F06.js) |
9 |
| - 6. [State Initializers](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F07.js) |
10 |
| - 7. [State Reducer](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F08.js) |
11 |
| - 8. [state reducer with types](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F09.js) |
12 |
| - 9. [Control Props](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F10-primer.js) |
13 |
| - 10. [Control Props + with a state reducer](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F10.js) |
14 |
| - 11. [Provider Pattern](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F11.js) |
15 |
| - 12. [Higher Order Components](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F12.js) |
16 |
| - 13. [Rendux](https://codesandbox.io/embed/github/kentcdodds/advanced-react-patterns-v2/tree/master/?module=%2Fsrc%2Fexercises-final%2F13.js) |
| 1 | +# Advanced React Patterns v2 |
| 2 | + |
| 3 | +👋 hi there! My name is [Kent C. Dodds](https://kentcdodds.com)! This is a |
| 4 | +workshop repo to teach you about using React Component Patterns to make your |
| 5 | +react components more useful and reusable without sacrificing simplicity. |
| 6 | + |
| 7 | +[![chat-badge][chat-badge]][chat] |
| 8 | +[![Build Status][build-badge]][build] |
| 9 | +[![AppVeyor Build Status][win-build-badge]][win-build] |
| 10 | +[![Code Coverage][coverage-badge]][coverage] |
| 11 | +[![MIT License][license-badge]][license] |
| 12 | +[](#contributors) |
| 13 | + |
| 14 | +[![PRs Welcome][prs-badge]][prs] |
| 15 | +[![Code of Conduct][coc-badge]][coc] |
| 16 | +[![Watch on GitHub][github-watch-badge]][github-watch] |
| 17 | +[![Star on GitHub][github-star-badge]][github-star] |
| 18 | +[![Tweet][twitter-badge]][twitter] |
| 19 | + |
| 20 | +## System Requirements |
| 21 | + |
| 22 | +* [git][git] v2.14.1 or greater |
| 23 | +* [NodeJS][node] v8.9.4 or greater |
| 24 | +* [npm][npm] v5.6.0 or greater |
| 25 | + |
| 26 | +All of these must be available in your `PATH`. To verify things are set up |
| 27 | +properly, you can run this: |
| 28 | + |
| 29 | +``` |
| 30 | +git --version |
| 31 | +node --version |
| 32 | +npm --version |
| 33 | +``` |
| 34 | + |
| 35 | +If you have trouble with any of these, learn more about the PATH environment |
| 36 | +variable and how to fix it here for [windows][win-path] or |
| 37 | +[mac/linux][mac-path]. |
| 38 | + |
| 39 | +## Setup |
| 40 | + |
| 41 | +You may be able to work through the entire workshop in the browser. Go to |
| 42 | +[this codesandbox](https://codesandbox.io/s/github/kentcdodds/advanced-react-patterns-v2) |
| 43 | +and you should be good to go. |
| 44 | + |
| 45 | +If you'd rather be able to work through the workshop on your own computer, then |
| 46 | +follow the following instructions. |
| 47 | + |
| 48 | +After you've made sure to have the correct things (and versions) installed, you |
| 49 | +should be able to just run a few commands to get set up: |
| 50 | + |
| 51 | +``` |
| 52 | +git clone https://github.com/kentcdodds/advanced-react-patterns-v2.git |
| 53 | +cd advanced-react-patterns-v2 |
| 54 | +npm run setup --silent |
| 55 | +``` |
| 56 | + |
| 57 | +This may take a few minutes. **It will ask you for your email.** This is |
| 58 | +optional and just automatically adds your email to the links in the project to |
| 59 | +make filling out some forms easier If you get any errors, please read through |
| 60 | +them and see if you can find out what the problem is. You may also want to look |
| 61 | +at [Troubleshooting](#troubleshooting). If you can't work it out on your own |
| 62 | +then please [file an issue][issue] and provide _all_ the output from the |
| 63 | +commands you ran (even if it's a lot). |
| 64 | + |
| 65 | +## Running the app |
| 66 | + |
| 67 | +To get the app up and running (and really see if it worked), run: |
| 68 | + |
| 69 | +```shell |
| 70 | +npm start |
| 71 | +``` |
| 72 | + |
| 73 | +This should start up your browser. If you're familiar, this is a standard |
| 74 | +[react-scripts](https://github.com/facebook/create-react-app) application. |
| 75 | + |
| 76 | +## Running the tests |
| 77 | + |
| 78 | +```shell |
| 79 | +npm test |
| 80 | +``` |
| 81 | + |
| 82 | +This will start [Jest](http://facebook.github.io/jest) in watch mode. Read the |
| 83 | +output and play around with it. |
| 84 | + |
| 85 | +**Your goal will be to go into each test, swap the final version for the |
| 86 | +exercise version in the import, and make the tests pass** |
| 87 | + |
| 88 | +## Troubleshooting |
| 89 | + |
| 90 | +<details> |
| 91 | + |
| 92 | +<summary>"npm run setup" command not working</summary> |
| 93 | + |
| 94 | +Here's what the setup script does. If it fails, try doing each of these things |
| 95 | +individually yourself: |
| 96 | + |
| 97 | +``` |
| 98 | +# verify your environment will work with the project |
| 99 | +node ./scripts/verify |
| 100 | +
|
| 101 | +# install dependencies |
| 102 | +npm install |
| 103 | +
|
| 104 | +# verify the project is ready to run |
| 105 | +npm run build |
| 106 | +npm run test:coverage |
| 107 | +``` |
| 108 | + |
| 109 | +If any of those scripts fail, please try to work out what went wrong by the |
| 110 | +error message you get. If you still can't work it out, feel free to |
| 111 | +[open an issue][issue] with _all_ the output from that script. I will try to |
| 112 | +help if I can. |
| 113 | + |
| 114 | +</details> |
| 115 | + |
| 116 | +## Contributors |
| 117 | + |
| 118 | +Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): |
| 119 | + |
| 120 | +<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> |
| 121 | + |
| 122 | +<!-- prettier-ignore --> |
| 123 | +| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub><b>Kent C. Dodds</b></sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/advanced-component-patterns-v2/commits?author=kentcdodds "Code") [📖](https://github.com/kentcdodds/advanced-component-patterns-v2/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/kentcdodds/advanced-component-patterns-v2/commits?author=kentcdodds "Tests") | |
| 124 | +| :---: | |
| 125 | + |
| 126 | +<!-- ALL-CONTRIBUTORS-LIST:END --> |
| 127 | + |
| 128 | +This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! |
| 129 | + |
| 130 | +## License |
| 131 | + |
| 132 | +This material is available for private, non-commercial use under the |
| 133 | +[GPL version 3](http://www.gnu.org/licenses/gpl-3.0-standalone.html). If you |
| 134 | +would like to use this material to conduct your own workshop, please contact me |
| 135 | + |
| 136 | + |
| 137 | +[npm]: https://www.npmjs.com/ |
| 138 | +[node]: https://nodejs.org |
| 139 | +[git]: https://git-scm.com/ |
| 140 | +[chat]: https://gitter.im/kentcdodds/advanced-react-patterns-v2 |
| 141 | +[chat-badge]: https://img.shields.io/gitter/room/kentcdodds/advanced-react-patterns-v2.js.svg?style=flat-square&logo=gitter-white |
| 142 | +[build-badge]: https://img.shields.io/travis/kentcdodds/advanced-react-patterns-v2.svg?style=flat-square&logo=travis |
| 143 | +[build]: https://travis-ci.org/kentcdodds/advanced-react-patterns-v2 |
| 144 | +[license-badge]: https://img.shields.io/badge/license-GPL%203.0%20License-blue.svg?style=flat-square |
| 145 | +[license]: https://github.com/kentcdodds/advanced-react-patterns-v2/blob/master/README.md#license |
| 146 | +[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square |
| 147 | +[prs]: http://makeapullrequest.com |
| 148 | +[donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square |
| 149 | +[donate]: http://kcd.im/donate |
| 150 | +[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square |
| 151 | +[coc]: https://github.com/kentcdodds/advanced-react-patterns-v2/blob/master/CODE_OF_CONDUCT.md |
| 152 | +[github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/advanced-react-patterns-v2.svg?style=social |
| 153 | +[github-watch]: https://github.com/kentcdodds/advanced-react-patterns-v2/watchers |
| 154 | +[github-star-badge]: https://img.shields.io/github/stars/kentcdodds/advanced-react-patterns-v2.svg?style=social |
| 155 | +[github-star]: https://github.com/kentcdodds/advanced-react-patterns-v2/stargazers |
| 156 | +[twitter]: https://twitter.com/intent/tweet?text=Check%20out%20advanced-react-patterns-v2%20by%20@kentcdodds%20https://github.com/kentcdodds/advanced-react-patterns-v2%20%F0%9F%91%8D |
| 157 | +[twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/advanced-react-patterns-v2.svg?style=social |
| 158 | +[emojis]: https://github.com/kentcdodds/all-contributors#emoji-key |
| 159 | +[all-contributors]: https://github.com/kentcdodds/all-contributors |
| 160 | +[win-path]: https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/ |
| 161 | +[mac-path]: http://stackoverflow.com/a/24322978/971592 |
| 162 | +[issue]: https://github.com/kentcdodds/advanced-react-patterns-v2/issues/new |
| 163 | +[win-build-badge]: https://img.shields.io/appveyor/ci/kentcdodds/advanced-react-patterns-v2.svg?style=flat-square&logo=appveyor |
| 164 | +[win-build]: https://ci.appveyor.com/project/kentcdodds/advanced-react-patterns-v2 |
| 165 | +[coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/advanced-react-patterns-v2.svg?style=flat-square |
| 166 | +[coverage]: https://codecov.io/github/kentcdodds/advanced-react-patterns-v2 |
| 167 | +[watchman]: https://facebook.github.io/watchman/docs/install.html |
0 commit comments