복붙노트

[REACTJS] JSON 응답의 동적 UI를 생성하는 방법에 반응 네이티브

REACTJS

JSON 응답의 동적 UI를 생성하는 방법에 반응 네이티브

해결법


  1. 1.'이 네이티브 반응'에서 가져 오기 {의 TextInput};

    '이 네이티브 반응'에서 가져 오기 {의 TextInput};

    당신은 상태로 반응을 매핑하면 this.setState (PickerValueHolder {});

    당신은 당신의 그것을 통해 다음 루프는지도 기능과 방법을 렌더링 할 수

      return(
        <View style={styles.container}>
          {this.state.PickerValueHolder.map(data=>(
            <View>
              <TextInput
                placeholder={data.placeholder}
                keyboardType={data.datatype==="int" ? 'numeric': 'default'}
                onChangeText={(text) => this.setState({...this.state.value [data.name]: text })}
                value={this.state.value[data.name]}
              />
              <Button
                onPress={this.handleButtonPress(data.name).bind(this)}
              />
            <View/>
          />
          ))}
        </View>
      )
    }```
    
    So here you are checking if the datatype is an int and then setting the keyboard type to numeric
    
    This is also setting all the changes to a value object in state.
    
    The Button calls a function with the name of of the value related to the text input
    
  2. from https://stackoverflow.com/questions/54801602/how-to-generate-dynaimc-ui-on-json-response-react-native by cc-by-sa and MIT license