0

I am trying to configure those radio buttons. When I run the app no one of those radio buttons is selected, while I need first one selected by default. I am using this code:

import React, { Component } from "react";
import { Container, Header, Content, ListItem, Text, Radio, Right } from "native-base";

export default class RadioButtonExample extends Component {

  constructor() {
    super();
    this.state = {
      itemSelected: "itemOne",
    };
  }

  render() {
    return (
      <Container>
        <Header />
        <Content>
          <ListItem onPress={() => this.setState({ itemSelected: "itemOne" })}>
            <Text>Daily Stand Up</Text>
            <Right>
              <Radio selected={this.state.itemSelected == "itemOne"} />
            </Right>
          </ListItem>
          <ListItem onPress={() => this.setState({ itemSelected: "itemTwo" })}>
            <Text>Discussion with Client</Text>
            <Right>
              <Radio selected={this.state.itemSelected == "itemTwo"} />
            </Right>
          </ListItem>
        </Content>
      </Container>
    );
  }
}

What should be fixed to make it work?

1 Answers1

0

You have to use "checked" attribute, try it.

Mosè Raguzzini
  • 15,399
  • 1
  • 31
  • 43