UNPKG

1.71 kBJavaScriptView Raw
1import * as React from 'react';
2import { View } from 'react-native';
3export const RadioButtonContext = /*#__PURE__*/React.createContext(null);
4/**
5 * Radio button group allows to control a group of radio buttons.
6 *
7 * <div class="screenshots">
8 * <figure>
9 * <img class="medium" src="screenshots/radio-button-group-android.gif" />
10 * <figcaption>Android</figcaption>
11 * </figure>
12 * <figure>
13 * <img class="medium" src="screenshots/radio-button-group-ios.gif" />
14 * <figcaption>iOS</figcaption>
15 * </figure>
16 * </div>
17 *
18 * ## Usage
19 * ```js
20 * import * as React from 'react';
21 * import { View } from 'react-native';
22 * import { RadioButton, Text } from 'react-native-paper';
23 *
24 * const MyComponent = () => {
25 * const [value, setValue] = React.useState('first');
26 *
27 * return (
28 * <RadioButton.Group onValueChange={newValue => setValue(newValue)} value={value}>
29 * <View>
30 * <Text>First</Text>
31 * <RadioButton value="first" />
32 * </View>
33 * <View>
34 * <Text>Second</Text>
35 * <RadioButton value="second" />
36 * </View>
37 * </RadioButton.Group>
38 * );
39 * };
40 *
41 * export default MyComponent;
42 *```
43 */
44
45const RadioButtonGroup = _ref => {
46 let {
47 value,
48 onValueChange,
49 children
50 } = _ref;
51 return /*#__PURE__*/React.createElement(RadioButtonContext.Provider, {
52 value: {
53 value,
54 onValueChange
55 }
56 }, /*#__PURE__*/React.createElement(View, {
57 accessibilityRole: "radiogroup"
58 }, children));
59};
60
61RadioButtonGroup.displayName = 'RadioButton.Group';
62export default RadioButtonGroup; // @component-docs ignore-next-line
63
64export { RadioButtonGroup };
65//# sourceMappingURL=RadioButtonGroup.js.map
\No newline at end of file