2016, AnjLab, Николай Жебрун
var state = { label: 'Name', value: 'AnjLab' }
var changeHandler = function() {
console.log('On input change')
}
var App = (
<Form>
<FormRow>
<FormLabel text={state.label} />
<FormInput value={state.value}
onChange={changeHandler}/>
</FormRow>
</Form>
);
React Desktop
React DOM Server Rendering
Testing
Single Store
console.log(store.getState());
Output:
{
form: {
value: 'AnjLab'
}
}
Store state is immutable
var action = {
type: CHANGE_VALUE,
value: 'TechTalks'
}
store.dispatch(action);
store.dispatch(action2);
...
Reducers make changes
function changeFormValue(state: {
value: 'Initial'
}, action) {
switch (action.type) {
case 'CHANGE_VALUE':
return { value: action.value };
default:
return state;
}
}
import { combineReducers, createStore } from 'redux';
let reducer = combineReducers({
form: changeFormValue
});
let store = createStore(reducer);
var styles = StyleSheet.create({
base: {
width: 38,
height: 38,
},
background: {
backgroundColor: '#222222',
},
active: {
borderWidth: 2,
borderColor: '#00ff00',
},
});
<Text style={styles.base} />
<View style={[
styles.base, styles.background
]} />
Dev NodeJS Packager
$ npm install
$ react-native run-ios
$ react-native run-android
Inspector & Perf Monitor
Systrace