Eirik Langholm Vullum PRO
JavaScript fanatic that loves node.js and React.
(Stockholm syndrome..?)
Oxymoron..?
I know all the languages
React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and React. The focus of React Native is on developer efficiency across all the platforms you care about — learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native.
What vs. how
element = createElement(...)
element.textContent = 'Submit form!';
element.style.backgroundColor = 'blue';
element.appendChild(...)
element.parentNode.parentNode...
<SubmitButton
color='blue'
text='Submit form!'
/>
Imperative (how)
Declarative (what)
UI = f(props, state)
const ChatApp = React.createClass({
...
render() {
return (
<div>
<FriendList friends={this.state.friends} />
<MessageList messages={this.state.messages} />
<MessageInput handleInput={this.handleInput} />
</div>
);
}
});
React
(virtual DOM)
(JavaScript)
DOM
(browser)
Application
state
patch DOM
patch DOM
props
change
React.js | React Native | |
---|---|---|
Block | <div> | <View> |
Inline | <span> | <Text> |
Image | <img> | <Image> |
List | <ul> | <ListView> |
// React.js
const Component = React.createClass({
render() {
return (
<div>
<span>Hello World</span>
<img src='...' />
</div>
);
}
});
// React Native
const Component = React.createClass({
render() {
return (
<View>
<Text>Hello World</span>
<Image source={{ uri: '...' }} />
</View>
);
}
});
(maps to native equivalents)
(making elements actionable)
(Inherent to native platforms)
(Inherent to specific platform)
const { Platform } = require('react-native');
if (Platform.OS === 'ios') {
// runs on ios..
}
if (Platform.OS === 'android') {
// runs on android..
}
/**
* requires ./App.android.js on Android
* requires ./App.ios.js on iOS
*/
const App = require('./App.js');
by Remy Sharp
A polyfill, or polyfiller, is a piece of code (or plugin) that provides the technology that you, the developer, expect the browser to provide natively. Flattening the API landscape if you will.
// React.js
const Component = React.createClass({
render() {
return (
<div style={styles.container}>
<span style={styles.text}>Hello</span>
</div>
);
}
});
const styles = {
container: {
flex: 1
backgroundColor: 'red',
},
text: {
color: 'green'
}
};
// React Native
const Component = React.createClass({
render() {
return (
<View style={styles.container}>
<Text style={styles.text}>Hello</Text>
</View>
);
}
});
const styles = StyleSheet.create({
container: {
flex: 1
backgroundColor: 'red',
},
text: {
color: 'green'
}
});
/**
* Need this to make socket.io
* work in production.
*
* JSCore is running on device
* which has no window.navigator.userAgent,
* but when you run in debug mode
* everythings runs in Chrome (V8)
* which does have window.navigator.userAgent
*/
if (!window.navigator.userAgent) {
window.navigator.userAgent = 'react-native';
}
@ericclemmons
Saul: “How’s it going?”
Me: “Fatigued.”
Saul: “Family?”
Me: “No, Javascript.”
Elm
Cycle.js
om
Section 3.3.2 of the iOS Developer Program explicitly permits this
provided that code does not change the primary or advertised purpose of the Application as submitted to the App Store.
By Eirik Langholm Vullum
Being a productive developer across platforms without being a unicorn