react-native-radio-buttons-group
Advanced tools
Comparing version 2.3.2 to 3.0.0
@@ -9,2 +9,3 @@ export type RadioButtonProps = { | ||
id: string; | ||
key?: string; | ||
label?: string; | ||
@@ -23,4 +24,5 @@ labelStyle?: object; | ||
layout?: 'row' | 'column'; | ||
onPress?: (radioButtons: RadioButtonProps[]) => void; | ||
onPress?: (selectedId: string) => void; | ||
radioButtons: RadioButtonProps[]; | ||
selectedId?: string; | ||
}; |
{ | ||
"name": "react-native-radio-buttons-group", | ||
"version": "2.3.2", | ||
"version": "3.0.0", | ||
"description": "Simple and Best. An easy to use radio buttons for react native apps.", | ||
@@ -32,9 +32,3 @@ "main": "./lib/index.ts", | ||
}, | ||
"homepage": "https://github.com/thakurballary/react-native-radio-buttons-group#readme", | ||
"dependencies": { | ||
"lodash.isequal": "4.5.0" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash.isequal": "4.5.6" | ||
} | ||
"homepage": "https://github.com/thakurballary/react-native-radio-buttons-group#readme" | ||
} |
@@ -31,3 +31,3 @@ # React Native Radio Buttons Group | ||
```jsx | ||
import React, { useState } from 'react'; | ||
import React, { useMemo, useState } from 'react'; | ||
import RadioGroup from 'react-native-radio-buttons-group'; | ||
@@ -37,3 +37,3 @@ | ||
const [radioButtons, setRadioButtons] = useState([ | ||
const radioButtons = useMemo(() => ([ | ||
{ | ||
@@ -49,7 +49,5 @@ id: '1', // acts as primary key, should be unique and non-empty string | ||
} | ||
]); | ||
]), []); | ||
function onPressRadioButton(radioButtonsArray) { | ||
setRadioButtons(radioButtonsArray); | ||
} | ||
const [selectedId, setSelectedId] = useState(); | ||
@@ -59,3 +57,4 @@ return ( | ||
radioButtons={radioButtons} | ||
onPress={onPressRadioButton} | ||
onPress={setSelectedId} | ||
selectedId={selectedId} | ||
/> | ||
@@ -72,3 +71,3 @@ ); | ||
```tsx | ||
import React, { useState } from 'react'; | ||
import React, { useMemo, useState } from 'react'; | ||
import RadioGroup, {RadioButtonProps} from 'react-native-radio-buttons-group'; | ||
@@ -78,3 +77,3 @@ | ||
const [radioButtons, setRadioButtons] = useState<RadioButtonProps[]>([ | ||
const radioButtons: RadioButtonProps[] = useMemo(() => ([ | ||
{ | ||
@@ -90,7 +89,5 @@ id: '1', // acts as primary key, should be unique and non-empty string | ||
} | ||
]); | ||
]), []); | ||
function onPressRadioButton(radioButtonsArray: RadioButtonProps[]) { | ||
setRadioButtons(radioButtonsArray); | ||
} | ||
const [selectedId, setSelectedId] = useState<string | undefined>(); | ||
@@ -100,3 +97,4 @@ return ( | ||
radioButtons={radioButtons} | ||
onPress={onPressRadioButton} | ||
onPress={setSelectedId} | ||
selectedId={selectedId} | ||
/> | ||
@@ -137,2 +135,3 @@ ); | ||
radioButtons | array | yes | | arrary of [RadioButton](#radiobutton) objects | ||
selectedId | string | no | | unique string | ||
@@ -139,0 +138,0 @@ ###### Horizontal (side by side) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
0
0
109670
143
153
- Removedlodash.isequal@4.5.0
- Removedlodash.isequal@4.5.0(transitive)