diff --git a/example-web/src/App.tsx b/example-web/src/App.tsx index a096bec4..e999d33f 100644 --- a/example-web/src/App.tsx +++ b/example-web/src/App.tsx @@ -8,7 +8,7 @@ import { // @ts-ignore } from 'react-native'; -import {examples, Props as ExamplesTabProperties} from './Examples'; +import {ControlledSliderExample, examples, Props as ExamplesTabProperties} from './Examples'; import {propsExamples, Props as PropsTabProperties} from './Props'; function App() { @@ -18,21 +18,17 @@ function App() { ) => { return ( - - {(filtered - ? (sliders as ExamplesTabProperties[]).filter( - e => !e.platform || e.platform === Platform.OS, - ) - : sliders - ).map((e, i) => ( - - {e.title} - {e.render()} - - ))} - + {(filtered + ? (sliders as ExamplesTabProperties[]).filter( + e => !e.platform || e.platform === Platform.OS, + ) + : sliders + ).map((e, i) => ( + + {e.title} + {e.render()} + + ))} ); }; @@ -41,8 +37,13 @@ function App() {
- {renderExampleTab(examples, true)} - {renderExampleTab(propsExamples)} + + {renderExampleTab(examples, true)} + {renderExampleTab(propsExamples)} + +
diff --git a/example-web/src/Examples.tsx b/example-web/src/Examples.tsx index ea34cca4..abad5657 100644 --- a/example-web/src/Examples.tsx +++ b/example-web/src/Examples.tsx @@ -1,8 +1,8 @@ -import React, {useState} from 'react'; +import React, {useRef, useState} from 'react'; // @ts-ignore -import {Text, View, StyleSheet, ScrollView} from 'react-native'; +import {Text, View, StyleSheet, ScrollView, Button} from 'react-native'; // @ts-ignore -import Slider, {SliderProps} from '@react-native-community/slider'; +import Slider, {SliderProps, SliderRef} from '@react-native-community/slider'; export interface Props { title: string; @@ -65,6 +65,31 @@ const SlidingCompleteExample = (props: SliderProps) => { export default SliderExample; + +export function ControlledSliderExample() { + const ref = useRef(null); + const [value, setValue] = useState(50); + return ( + + Controlled Slider + {value && +value.toFixed(3)} + + +