Name: training-react
Owner: Xebia BV
Description: null
Created: 2016-04-30 15:46:29.0
Updated: 2017-06-02 08:02:33.0
Pushed: 2017-11-07 08:04:45.0
Homepage: null
Size: 174
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
install
n the app in development mode.
start
start
n tests on file change
run test
test
ild the app for production in the "build" folder
run build
build
Each folder contains an example or an exercise. There are no dependencies between the separate folders. Create-react-app is used to provide auto reloading and displaying error messages. It allows us to focus on application code instead of looking at build configuration.
Hello world:
Timer:
Shows that React can be used without any tooling like JS transpilation. The example itself can be opened without using NodeJS or npm. Open either ./public/es5-nojsx-examples/helloworld.html or ./public/es5-nojsx-examples/timer.html in a browser.
helloworld.html
show the basics of creating a React component and has a loop. timer.html
show a React component which uses state.
Hello world:
Timer:
Same examples as above using ES6 transpilation and JSX. It shows that React components can be written down much more concise and readable in JSX with ES6 compares to in plain ES5.
Exercise to work with snapshot tests and enzyme. Note that a single snapshot is enough for this components, but we want to use Enzyme as well for practice.
http://localhost:3000/?component=JsxExercise
Exercise to get familiar with building React components using JSX. The goal is to reproduce the page shown here. The data structure for the contents of the page can be found in ./src/jsx-exercise/data.js. The exercise has the following steps:
http://localhost:3000/?component=ReactForm
Exercise to work with stateful components in React. The state of the component is displayed on the page to make debugging easier.
setState
to the component. NOTE: make sure that this
in the change handler points to the instance of the component.http://localhost:3000/?component=ReactGiphySearch
Exercise to make an ajax call from React. The view and components are already available. The file to edit is ./src/react-giphy-search/giphy-search/GiphySearchPage.js.
onSubmit
handler which calls preventDefault
onSubmit
handler:searchGiphy
which is located in ./src/react-giphy-search/giphy-search/giphy-search-service.js to fetch a list of giphy'ssearchGiphy
returns a promise of the response of the backend. Inspect/log the data to determine how to use it.Error
instancemessage
field in the state to display possible errorssetState
in the then
callback of the promiseShows that reducers are easy to test because they are plain JS functions
http://localhost:3000/?component=ConnectReduxToReact
A redux store has been defined which will update its state with a random giphy. The goal is to connect this store to the provided view.
http://localhost:3000/?component=SimpleReduxFrom
http://localhost:3000/?component=ReactGiphySearch
Implement an async action creator to search for giphy's.
submitSearch
in ./src/redux-giphy-search/giphy-search/giphy-search-actions.jsSUBMIT_SEARCH
eventGIPHY_RESPONSE
eventGIPHY_ERROR
eventThe goal of this exercise is to lean how to make asynchronous tests. It will also become clear that when a test is async it will be difficult to write.
done
callback of mocha when the test is asyncassertDispatchCall
to perform assertions on the n-th call of dispatchassertDispatchCall
returns a dispatchMock
Reselect enables high performing calculated properties in redux. In this exercise we are going to calculate the total payload size of the giphy's shown in the giphy search exercise.
createSelector
giphy.images.original.mp4_size
map
and reduce
getTotalGiphyPayloadSize
in mapStateToProps
in ./src/redux-giphy-search/giphy-search/GiphySearchPage.jspropType
validation for the new property