mirror of
https://github.com/zhigang1992/react-native-slider.git
synced 2026-01-12 22:50:54 +08:00
Use modern JS/React syntax for the example usage
This commit is contained in:
42
README.md
42
README.md
@@ -32,47 +32,41 @@ npm i --save react-native-slider
|
||||
## Usage
|
||||
|
||||
```jsx
|
||||
'use strict';
|
||||
import React from "react";
|
||||
import Slider from "react-native-slider";
|
||||
import { AppRegistry, StyleSheet, View, Text } from "react-native";
|
||||
|
||||
var React = require('react');
|
||||
var Slider = require('react-native-slider');
|
||||
var {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
View,
|
||||
Text,
|
||||
} = require('react-native');
|
||||
|
||||
var SliderExample = React.createClass({
|
||||
getInitialState() {
|
||||
return {
|
||||
value: 0.2,
|
||||
};
|
||||
},
|
||||
class SliderExample extends React.Component {
|
||||
state = {
|
||||
value: 0.2
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Slider
|
||||
value={this.state.value}
|
||||
onValueChange={(value) => this.setState({value})} />
|
||||
<Text>Value: {this.state.value}</Text>
|
||||
onValueChange={value => this.setState({ value })}
|
||||
/>
|
||||
<Text>
|
||||
Value: {this.state.value}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
marginLeft: 10,
|
||||
marginRight: 10,
|
||||
alignItems: 'stretch',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
alignItems: "stretch",
|
||||
justifyContent: "center"
|
||||
}
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('SliderExample', () => SliderExample);
|
||||
AppRegistry.registerComponent("SliderExample", () => SliderExample);
|
||||
```
|
||||
|
||||
## Props
|
||||
|
||||
Reference in New Issue
Block a user