Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Flexdirection:'row' #5

Open
kamleshchandnani opened this issue Mar 23, 2017 · 5 comments
Open

Issue with Flexdirection:'row' #5

kamleshchandnani opened this issue Mar 23, 2017 · 5 comments

Comments

@kamleshchandnani
Copy link

When i set flex direction to row and flexWrap to 'wrap' then there is unnecessary height the radio button takes up, also it doesn't grows the parent container to show all the radios
css

radioGroup: {
    flexDirection: 'row',
    flexWrap: 'wrap',
    marginTop: 20,
    marginBottom: 10
  },
  radioView: {
    width: '40%',
    // flexWrap: 'wrap',
    flexGrow: 1,
    alignItems: 'flex-start',
    paddingRight: 2
  },
<View>
 <RadioGroup style={productStyles.radioGroup}
                  selectedIndex={this.state.categoryIndex}
                  onSelect={(index, value) => { this.changeHandler('categoryValue', value, index) }}
                >
                  {
                    this.state.category.map((data, index) => (
                      <RadioButton key={index} value={data.id} style={productStyles.radioView}>
                        <Text style={{ color: '#666666' }}>{data.name}</Text>
                      </RadioButton>
                    ))
                  }
                </RadioGroup>
</View>
@thegamenicorus
Copy link
Owner

Could you take screenshot or explain more info, please.

Thank you.
:)

@ghost
Copy link

ghost commented Mar 16, 2018

@kamleshchandnani would you please explain me the mapping concept in your code for index field. I need to make selectedIndex = {this.state.index} so that already saved radio button will appear as selected. Please help me with this. All i want to ask is how did you create your array of "data" with respective index value?

@kamleshchandnani
Copy link
Author

kamleshchandnani commented Mar 17, 2018

@khushboogupta1
Array of Data

[
  {
    "id": 1,
    "name": "Item1"
  },
  {
    "id": 2,
    "name": "Item2"
  },
  {
    "id": 3,
    "name": "Item3"
  }
]

I passed onSelect a function like below

 onSelect={(index, value) => { this.changeHandler('categoryValue', value, index) }} 

so I also pass index to this function along with 'categoryValue' and index, and the 'changeHandler' function is implemented in the following way.

changeHandler = (type, value, index) => {
  if(type = "categoryValue"){
    this.setState({
      categoryValue: value,
      categoryIndex: index
    })
  }
}

So the radio gets selected as because selectedIndex={this.state.categoryIndex} evaluates to the actual index value.

@Swap00Seven
Copy link

Swap00Seven commented Aug 13, 2019

Were you able to place radio buttons on a single row?
Please let me know how can we do that.

@vjazz
Copy link

vjazz commented Aug 30, 2019

I only placed style={{flexDirection:'row'}} in RadioGroup and my button is in row now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants