gpt4 book ai didi

javascript - 使用 redux 时出现 eslint 奇怪的错误

转载 作者:行者123 更新时间:2023-11-29 23:31:01 25 4
gpt4 key购买 nike

<分区>

我从 eslint 收到了这个警告,我正在使用 create-react-app。

./src/components/auth.js
Line 24: Unexpected labeled statement no-labels
Line 24: 'authenticated:' is defined but never used no-unused-labels
Line 24: Expected an assignment or function call and instead saw an expression no-unused-expressions

而且我认为我下面的组件没有任何问题,这太烦人了

import React, { Component } from 'react';
import { connect } from 'react-redux';

export default function(ComposedComponent) {
class Authentication extends Component {

componentWillMount() {
if (!this.props.authenticated) {
this.props.history.replace('/login');
}
}

componentWillUpdate(nextProps) {
if (!nextProps.authenticated) {
this.props.history.replace('/login');
}
}

render() {
return <ComposedComponent {...this.props} />
}
}

return connect(state => {authenticated: state.auth.authenticated})(Authentication);
}

我不知道应该修复什么,第一次使用 eslint。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com