当前位置: 首页 > 知识库问答 >
问题:

如何解决React本机的警告消息

戚承业
2023-03-14

我现在正在学习React本地,最近我收到了下面的日志消息

{“名称”:“PropertyFinder”、“版本”:“0.0.1”、“private”:true、“脚本”:{“start”:“node node_modules/react-native/local-cli/cli.js start”、“test”:“jest”}、“dependencies”:{“react”:“^16.2.0”、“react-native”:“0.54.0”、“react-native:^1.3.0”}、“devdependencies”:{“babel-jest”:“22.4.1”、“babel-preset-react-native”:“,”笑话“:{”预置“:”反应-本机“}}

但仍显示警告。

SearchPage.js

'use strict';

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  TextInput,
  View,
  Button,
  ActivityIndicator,
  Image
} from 'react-native';
// import { StackNavigator } from 'react-navigation';

export default class SearchPage extends Component<{}> {
  static navigationOptions = {
    title: 'Property Finder',
  };

  constructor(props) {
    super(props);
    this.state = {
      searchString: 'london'
    };
  }

  _onSearchTextChanged = (event) => {
    console.log('_onSearchTextChanged');
    this.setState({
      searchString: event.nativeEvent.text
    });
    console.log('Current: ' + this.state.searchString + ', Next: ' + event.nativeEvent.text);
  }

  render() {
    console.log('SearchPage render');

    return (
      <View style={styles.container}>
        <Text style={styles.description}>
          Search for houses to buy!
        </Text>      
        <Text style={styles.description}>
          Search by place-name or postcode.
        </Text>
        <View style={styles.flowRight}>
          <TextInput
            underlineColorAndroid={'transparent'}
            style={styles.searchInput}
            value={this.state.searchString}
            onChange={this._onSearchTextChanged}
            placeholder='Search via name or postcode' />
          <Button
            onPress={() => {}}
            color='#48bbec'
            title='Go'
          />
        </View>
        <Image source={require('./Resources/house.png')} style={styles.image} />
      </View>    
    );
  }
}

const styles = StyleSheet.create({
  description: {
    fontSize: 18,
    textAlign: 'center',
    color: '#656565',
    marginBottom: 20,
  },
  container: {
    padding: 30,
    marginTop: 65,
    alignItems: 'center',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
  flowRight: {
    flexDirection: 'row',
    alignItems: 'center',
    alignSelf: 'stretch',
  },
  searchInput: {
    height: 36,
    padding: 4,
    marginRight: 5,
    flexGrow: 1,
    fontSize: 18,
    borderWidth: 1,
    borderColor: '#48bbec',
    borderRadius: 8,
    color: '#48bbec',
  },
  image: {
    width: 217,
    height: 138,
  },
});

app.js

'use strict';
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  View
} from 'react-native';
import { StackNavigator } from 'react-navigation';

import SearchPage from './SearchPage';

// type Props = {};


const App = StackNavigator({
  Home: {
    screen: SearchPage,
  },
});
export default App;

对不起,我的英语不好。

共有1个答案

薛承基
2023-03-14

在此处输入链接描述

在React V16.3之后,根据生命周期功能进行了调整,然后,熟悉它。

 类似资料:
  • 我收到这些警告消息,但我不确定如何修复: 02-14 14:01:15.255:I/DalVikVM(10677):找不到方法Android.View.ViewGroup.OnStopnestedScroll,从方法Android.Support.v7.Internal.Widget.ActionBarOverLayLayout.OnStopnestedScroll引用 02-14 14:01:1

  • 问题内容: DeprecationWarning:需要一个整数(got类型为float)。不建议使用隐式转换为整数,并且在将来的Python版本中可能会删除隐式转换。 DeprecationWarning:需要一个整数(got类型为float)。不建议使用隐式转换为整数,并且在将来的Python版本中可能会删除隐式转换。 问题答案: 警告与的坐标参数有关。浮点坐标将表示的原点位于窗口像素之间。那没

  • 使用google wire,代码总是有告警信息,但是编译运行正常,如何去掉告警信息? 代码如下: 如图,代码中 package 有告警,告警信息内容: This file is within module ".", which is not included in your workspace. To fix this problem, you can add a go.work file tha

  • 我有一个数据框 我正在执行以下功能 但是,当我这样做时,我收到警告: 我如何解决这个问题? Lorem ipsum dolor sit amet,consecetur adipiscing elit,sed do eiusmod temor附带ut labore et dolore magna aliqua。Ut enim ad minim veniam,quis nostrud练习ullamco

  • 问题内容: 使用React 16.8.6(在以前的版本16.8.3中很好),当我尝试防止在获取请求上发生无限循环时,出现此错误 我一直找不到停止无限循环的解决方案。我想远离使用。我确实在https://github.com/facebook/react/issues/14920找到了这个讨论,在这里可能的解决方案是我不确定自己在做什么,所以我还没有尝试实现它。 我有这个当前设置,React钩子us

  • vue3 新的 defineModel parent: <Input v-model:p_input="test_input" /> son: <el-input v-model="myInput" placeholder="Please input" /> 报警告: Extraneous non-emits event listeners (refresh) were passed to com