learn the principles about React. • Learn whats behind `redux` and the unidirectional data flow. • Get some understanding on why and how we’ve chosen the stack for the UI rewrite. • Write an example ToDo Application.
React is NOT a framework. • It’s all about composable and modular components. • It makes no assumptions about your build/technology-stack. • Managing state with the DOM is hard. • Thats why React re-renders the whole application on each change.
current virtual DOM element. • All changes are batched before applying them into the real DOM. • Optimized for performance, performance, performance! Every JavaScript developer in 2014
always have a clear unidirectional flow. In React this is implemented with `props`. • Props, or properties, are always passed from the outside into the components. • Props cannot be modified. • If a parent re-renders and passes a different value for the prop, the component will be re-rendered as well.
always have a clear unidirectional flow. In React this is implemented with `props`. • Props, or properties, are always passed from the outside into the components. • Props cannot be modified. • If a parent re-renders and passes a different value for the prop, the component will be re-rendered as well. State: • If you need to modify a value inside a componnt, you should first evaluate why. • If that’s not possible, a React component can hold it’s own state. • If you mutate the state, the component will be re-rendered.
const Button = props => ( <button role="button" onClick={props.onClick}> {props.children} </button> ); Button.propTypes = { onClick: PropTypes.func.isRequired, children: PropTypes.node.isRequired }; Button.defaultProps = { onClick: () => null } export default Button; Fat-Arrow syntax, basically a function which has one argument `props` and returns the JSX markup. JSX is pretty much XHTML syntax which will be transpiled into raw JavaScript.
const Button = props => ( <button role="button" onClick={props.onClick}> {props.children} </button> ); Button.propTypes = { onClick: PropTypes.func.isRequired, children: PropTypes.node.isRequired }; Button.defaultProps = { onClick: () => null } export default Button; Fat-Arrow syntax, basically a function which has one argument `props` and returns the JSX markup. JSX is pretty much XHTML syntax which will be transpiled into raw JavaScript. With React, you can implement a low-level type safety with `propTypes`.
const Button = props => ( <button role="button" onClick={props.onClick}> {props.children} </button> ); Button.propTypes = { onClick: PropTypes.func.isRequired, children: PropTypes.node.isRequired }; Button.defaultProps = { onClick: () => null } export default Button; Fat-Arrow syntax, basically a function which has one argument `props` and returns the JSX markup. JSX is pretty much XHTML syntax which will be transpiled into raw JavaScript. With React, you can implement a low-level type safety with `propTypes`. … and you can provide default values, in case you want to make the life of a developer easier.
facebook in 2014 for building react applications • Basically reduced CQRS, but… things got worse since people tended to create multiple instances of Flux in one application (UserStore, OrderStore).
action) { switch (action.type) { case 'INCREMENT': return state + 1 case 'DECREMENT': return state - 1 default: return state } } const actions = { increment: () => { type: 'INCREMENT' }, decrement: () => { type: 'DECREMENT' } } const store = createStore(counter); store.subscribe(() => console.log(store.getState()) ); store.dispatch(actions.increment()) // 1 store.dispatch(actions.increment()) // 2 store.dispatch(actions.decrement()) // 1 Redux: Let’s see some code 1) Reducer, mutates and returns the new state. 2) Create the store instance. 3) Subscribe to updates. 4) Dispatch actions, which will mutate the state through the switch statement. 2) Action creators will create the action objects with the desired payload
StyleLint • Karma, Chai, Sinon, Enzyme, WebdriverIO • NPM • Travis CI & Codeclimate More info on https://github.com/PackageFactory/PackageFactory.Guevara#development-commands
guest frame are independent & encapsulated applications The redux store handles all interactions & business logic Neos JS API Handles the communication with the server.