передача состояния массива другому классу

df = pd.DataFrame({'countries':['US','UK','Germany','China']})
countries = ['UK','China']

реализовать в:

df[df.countries.isin(countries)]

реализовать не так, как в странах покоя:

df[df.countries.isin([x for x in np.unique(df.countries) if x not in countries])]
0
задан keepAlive 16 January 2019 в 13:49
поделиться

2 ответа

Пожалуйста, замените ваш код следующим:

Главный экран

class HomeScreen extends React.Component {
//initial
constructor(props) {
  super(props);
  this.state = {
    isReady: false,
    myMenu: '????',
    menutext: '',
    randomArray: ['a', 'b', 'c'],
  };
}

render() {


    return (
      <View style={[styles.mainContainer]}>
        <DetailsScreen menuListAA={this.state.randomArray} />
        <Button
          label="Show all menu"
          onPress={() => {
            /* 1. Navigate to the menu page route with params */
            this.props.navigation.navigate('Details', {
              itemId: 0,
              otherParam: 'Show all menu',
            });
          }}
        />

      </View>

Сомнения подробно : заменить View на [113 ] компонент

class DetailsScreen extends React.Component {


  constructor(props) {
    super(props);
    this.state = {

    }
  }
  static navigationOptions = {
    title: 'All menu',
  };

loadMenuList() {
  const allMenuList = this.props.menuListAA;
  return allMenuList.map((item, index) => <Text key={index}>{item}</Text>);

}

  render() {

    return (
      <ScrollView>

//change View with Text as view cannot render characters and error says the same

        <Text style={styles.row}>{this.props.menuListAA}</Text>

        <Button
          label="Go back"
          onPress={() => this.props.navigation.goBack()}
        />
      </ScrollView>
    );
  }
}

const RootStack = createStackNavigator(
  {
    Home: HomeScreen,
    Details: DetailsScreen,
  },
  {
    initialRouteName: 'Home',
  }
);

const AppContainer = createAppContainer(RootStack);

export default class App extends React.Component {

  render() {
    return <AppContainer />;
  }
}
0
ответ дан Firu 16 January 2019 в 13:49
поделиться

вы можете передавать данные от родителя к потомку, устанавливая реквизиты для дочернего компонента, например: <Child data={this.state.yourData} /> //the props name is data, затем в дочернем компоненте в componentWillMount() вы можете получить к нему доступ:

ComponentWillMount(){ 
    this.setState({childData: this.props.data}) // childData is an state of child component,rename it to your own` 
}

в некоторых данных случая может быть изменено, поэтому мы должны проверить это в componentDidUpdate():

componentDidUpdate(){
     if(this.props.data != this.state.childData){ //it is necessary because this function called many time's 
            this.setState({childData: this.props.data})
}

, если вы были в parent & amp; Если вы хотите передать какие-либо данные от ребенка, вы должны передать функцию, которая возвращает данные, как показано ниже:

<Child getData={(value)=> console.log(value)} />

, тогда у вашего ребенка вы можете сделать это:

this.props.getData(anyDataYouWantGetInParent)

надеюсь, что этот ответ будет будь любезен, дай мне знать любой вопрос, удачи.

0
ответ дан amirhosein 16 January 2019 в 13:49
поделиться
Другие вопросы по тегам:

Похожие вопросы: