Javascript 道具验证中缺少功能组件中的道具

Javascript 道具验证中缺少功能组件中的道具,javascript,reactjs,react-native,eslint,react-proptypes,Javascript,Reactjs,React Native,Eslint,React Proptypes,Eslint抛出Eslint(反应/道具类型)错误,尽管已声明道具类型。我正在使用 我已经研究了几个其他类似的问题,以及其他的问题,但它们没有解决我的问题 import React from 'react'; import { View, Text, TouchableHighlight, StyleSheet } from 'react-native'; import PropTypes from 'prop-types'; const PASTEL_PINK = '#dea5a4'; co

Eslint抛出Eslint(反应/道具类型)错误,尽管已声明道具类型。我正在使用

我已经研究了几个其他类似的问题,以及其他的问题,但它们没有解决我的问题

import React from 'react';
import { View, Text, TouchableHighlight, StyleSheet } from 'react-native';
import PropTypes from 'prop-types';

const PASTEL_PINK = '#dea5a4';
const PASTEL_BLUE = '#779ecb';

const Buttons = ({ onPressStart, onPressPause, onPressReset, onGoing }) => (
  <View >
    <TouchableHighlight
      onPress={onPressStart}
      disabled={onGoing}
    >
      <Text >{START_TIMER}</Text>
    </TouchableHighlight>
    <TouchableHighlight
      onPress={onPressPause}
      disabled={!onGoing}
    >
      <Text >{PAUSE_TIMER}</Text>
    </TouchableHighlight>
    <TouchableHighlight onPress={onPressReset}>
      <Text >{RESET_TIMER}</Text>
    </TouchableHighlight>
  </View>
);

Buttons.protoTypes = {
  onPressStart: PropTypes.func.isRequired,
  onPressPause: PropTypes.func.isRequired,
  onPressReset: PropTypes.func.isRequired,
  onGoing: PropTypes.bool.isRequired,
};

export default Buttons;
从“React”导入React;
从“react native”导入{View,Text,TouchableHighlight,StyleSheet};
从“道具类型”导入道具类型;
const PASTEL_PINK='dea5a4';
康斯特粉彩蓝='779ecb';
常量按钮=({onPressStart、onPressPause、onPressReset、Continuous})=>(
{启动计时器}
{暂停计时器}
{RESET_TIMER}
);
按钮。原型={
onPressStart:PropTypes.func.isRequired,
onPressPause:PropTypes.func.isRequired,
按重置:需要PropTypes.func,
正在进行:PropTypes.bool.isRequired,
};
导出默认按钮;
提供道具的父组件

import React from 'react';
import Buttons from './components/Buttons'
import Container from './components/Container';
import Timer from './components/Timer';
import Inputs from './components/Inputs';
import Logo from './components/Logo';
import Buttons from './components/Buttons'
import Header from './components/Header'

export default class Home extends React.Component {
  constructor(props){
    super(props)
    this.state = {
      initialMinute: '00',
      initialSecond: '00',
      minute: '00',
      second: '00',
      completed: false,
      onGoing: false,
    }

  componentWillMount() {
    this.setState({
        minute: this.state.initialMinute,
        second: this.state.initialSecond,
      }
    );
  }

  componentWillUnmount() {
    clearInterval(this.interval);
  }

  startTimer = () => {
    console.log("Timer Started")
    this.setState(
      (prevState) => (
        {
          completed: false,
          onGoing: true,
        }
      )
    )
    // start the timer
    this.interval = setInterval(
      this.decrementTime,
      1000
    )
  }

  decrementTime = () => {
    if (this.state.second > 0) {
      console.log(`second: ${this.state.second}`)
      this.setState(
        (prevState) => (
          {second: prevState.second - 1}
        )
      )
      if (this.props.second < 10) {
        this.setState({
            second: '0'+this.state.second
        });
      }
    }
    else {
      if (this.state.minute > 0) {
        this.setState(
          (prevState) => (
            {
              minute: prevState.minute - 1,
              second: prevState.second + 59,
            }
          )
        )
        if (this.props.minute < 10) {
          this.setState({
              state: '0'+this.state.minute
          });
        }
      }
      else {
        this.resetTimer();
        this.timesUp(true);
      }
    }
  }

  pauseTimer = () => {
    console.log("Timer stopped")
    clearInterval(this.interval);
    this.setState({
        onGoing: false,
      }
    )
  }

  resetTimer = () => {
    console.log("Timer is reset")
    this.pauseTimer();
    this.setState({
        minute: this.state.initialMinute,
        second: this.state.initialSecond,
      }
    );
  }

  timesUp = (bool) => {
    this.setState(
      (prevState) => (
        {
          completed: bool,
        }
      )
    )
  }


  optionPressed = () => {
    console.log("Header is pressed")
  }

  handleMinuteInput = (text) => {
    // clamp minute between 0 and 60
    // const number = helper.clamp(parseInt(text), 0, 60)
    this.setState(
      {
        initialMinute: text,
      }
    )
  }

  handleSecondInput = (text) => {
    // const number = helper.clamp(parseInt(text+''), 0, 60)
    this.setState(
      {
        initialSecond: text,
      }
    )
  } 

  render() {
    return (
      <Container>
        <Header onPress={this.optionPressed}/>
          <Logo 
            slogan={'Get studying, the Pomodoro way!'}
            imageSource={'../../assets/pomo-timer-logo-small.png'}
          />
          <Timer 
            minute={this.state.minute}
            second={this.state.second}
            completed={this.state.completed}
            onGoing={this.state.onGoing}
          />
          <Buttons 
            onPressStart={this.startTimer}
            onPressPause={this.pauseTimer}
            onPressReset={this.resetTimer}
            onGoing={this.state.onGoing} // true when not onGoing
          />
          <Inputs 
            inputType={'Work'}
            labelColor={PASTEL_BLUE}
            handleMinuteInput={this.handleMinuteInput}
            handleSecondInput={this.handleSecondInput}
            onGoing={this.state.onGoing}
          />
          <Inputs
            inputType={'Rest'}
            labelColor={PASTEL_PINK}
            // setTimer={this.setTimer}
            handleMinuteInput={this.handleMinuteInput}
            handleSecondInput={this.handleSecondInput}
            onGoing={this.state.onGoing}
          />
      </Container>
    )
  }
}
从“React”导入React;
从“./components/Buttons”导入按钮
从“./组件/容器”导入容器;
从“./components/Timer”导入计时器;
从“./组件/输入”导入输入;
从“./components/Logo”导入徽标;
从“./components/Buttons”导入按钮
从“./components/Header”导入标题
导出默认类Home扩展React.Component{
建造师(道具){
超级(道具)
此.state={
首字母分钟:“00”,
首字母秒:“00”,
分钟:"00",,
第二:'00',,
已完成:错误,
进行中:错误,
}
组件willmount(){
这是我的国家({
分钟:this.state.initialMinute,
第二个:this.state.initialSecond,
}
);
}
组件将卸载(){
clearInterval(这个.interval);
}
startTimer=()=>{
日志(“计时器启动”)
这是我的国家(
(prevState)=>(
{
已完成:错误,
正在进行的:是的,
}
)
)
//启动计时器
this.interval=setInterval(
这个,递减时间,
1000
)
}
递减时间=()=>{
如果(this.state.second>0){
console.log(`second:${this.state.second}`)
这是我的国家(
(prevState)=>(
{second:prevState.second-1}
)
)
如果(本秒<10){
这是我的国家({
秒:“0”+此.state.second
});
}
}
否则{
如果(this.state.minute>0){
这是我的国家(
(prevState)=>(
{
分钟:prevState.minute-1,
第二名:prevState.second+59,
}
)
)
如果(此.props.minute<10){
这是我的国家({
状态:“0”+this.state.minute
});
}
}
否则{
这是resetTimer();
此.timesUp(true);
}
}
}
pauseTimer=()=>{
日志(“计时器停止”)
clearInterval(这个.interval);
这是我的国家({
进行中:错误,
}
)
}
重置计时器=()=>{
日志(“计时器被重置”)
这是pauseTimer();
这是我的国家({
分钟:this.state.initialMinute,
第二个:this.state.initialSecond,
}
);
}
timesUp=(bool)=>{
这是我的国家(
(prevState)=>(
{
完成:布尔,
}
)
)
}
选项按下=()=>{
日志(“按下标题”)
}
handleMinuteInput=(文本)=>{
//0到60之间的钳位分钟数
//const number=helper.clamp(parseInt(文本),0,60)
这是我的国家(
{
第一分钟:文本,
}
)
}
handleSecondInput=(文本)=>{
//const number=helper.clamp(parseInt(text+“”),0,60)
这是我的国家(
{
第二:文本,
}
)
} 
render(){
返回(
)
}
}
我不希望这些错误出现,但它确实出现了

道具验证中缺少“onPressStart” 道具验证中缺少“onPressPause” 道具验证中缺少“onPressReset” 道具验证中缺少“正在进行”替换

Buttons.protoTypes 


这个错误我已经犯了太多次了

这是
propTypes
,而不是
prototype
:)

你能把给这个组件提供道具的代码贴出来吗?谢谢!我犯了太多这样的错误,没有注意到它。
Buttons.propTypes