How to implement radio button in React Native

前端 未结 8 2290
不思量自难忘°
不思量自难忘° 2020-12-25 11:18

I am converting React code to React Native. So I need to implement radio buttons.

8条回答
  •  礼貌的吻别
    2020-12-25 11:59

    Maybe you could style into a circle button such as a radio button or something: example Tabs or same concept

    const period = [
          {
            key: 1,
            name : '1 Month',
            value : 1,
    
          },
          {
            key : 2,
            name : '12 Month',
            value : 12,
    
          }
        ];
    
        constructor(props) {
            super(props);
            this.state = {
              value: 0,
            };
          }
    
        onChangeTabs = (tabs) => {
    
            this.setState({
              value : tabs,
    
            })
    
          }
    
        renderTabs = () => {
            return period.map(item => (
              
                
                  {item.name}
                
              
            ));
          };
    
    
        const styles = StyleSheet.create({
        period: {
            borderRadius: 5,
            borderColor: '#fff',
            borderWidth: 1,
    
            marginHorizontal: 5,
          },
          periodActive: {
            backgroundColor: '#333',
          },
        });
    

提交回复
热议问题