小编Ned*_* DN的帖子

不推荐通过主React包访​​问PropTypes

我正在使用redux但是当我运行我的代码时出现此错误:

不推荐通过主React包访​​问PropTypes.请改用npm中的prop-types包.

我安装

npm i prop-types -S

但我仍然有同样的错误.

./components/action/article.js

import * as ArticleActionTypes   from '../actiontypes/article';

export const AddArticle = (name, description, prix, image) => {
    return {
        type: ArticleActionTypes.ADD_ARTICLE,
        name, 
        description, 
        prix,
        image
    }
}

export const RemoveArticle = index => {
    return {
        type: ArticleActionTypes.REMOVE_ARTICLE,
        index
    }
}
Run Code Online (Sandbox Code Playgroud)

./components/actiontypes/article.js

export const ADD_ARTICLE = 'article/ADD_ARTICLE';
export const REMOVE_ARTICLE = 'article/REMOVE_ARTICLE';
export const UPDATE_ARTICLE = 'article/UPDATE_ARTICLE';
Run Code Online (Sandbox Code Playgroud)

./components/reducers/article.js

import * as ArticleActionTypes   from '../actiontypes/article';

const initialState = [
    {
        name: 'test',
        description: …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux react-proptypes

33
推荐指数
3
解决办法
2万
查看次数

在React中将字符串转换为日期

我从JSON对象中以字符串格式检索了一个日期变量,但是直到现在为止我都无法获得经过的时间。

import React from 'react';

export default class Date extends React.Component {
render() {

    console.log(this.props.date); //shows: 2017-01-25T10:18:18Z

    var date = Date.parse(this.props.date.toString());

    console.log(date.getTime());

    return (
        <div >
      </div>
    );
   }
}
Run Code Online (Sandbox Code Playgroud)

javascript json reactjs

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

javascript ×2

reactjs ×2

json ×1

react-proptypes ×1

redux ×1