问题描述
我正在尝试处理有关需要在 NPM 程序中包含 prop-types 包的新警告.我的应用是电子应用.
I am trying to deal with the new warning about needing to include the prop-types package in NPM programs. My app is an electron app.
我想我正在遵循 React 人员的迁移策略:https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html
I think I am following the migration strategy from the React folks: https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html
react version-15.4.2,prop-types version 15.5.8,react-dom 15.42.2
react version-15.4.2, prop-types version 15.5.8, react-dom 15.42.2
但是,我在添加 prop-types 包后仍然收到警告.
However, I am still getting the warning after adding the prop-types package.
这是组件(Dashboard.jsx)
This is the component (Dashboard.jsx)
const React = require('react')
const { Component } = require('react')
const {} = require('react-bootstrap')
import PropTypes from 'prop-types'
import { App, Title, Section, Header, Footer, Columns, Box, Button } from 'grommet'
export const Page = props => (
<App>
<Title>Dashboard Version 1.0, Node version: xxx</Title>
<Section>Status Section
<p>Status: {props.serverState}</p>
</Section>
<Section >{/* colorIndex='neutral-1' */ }
<Header>Controls</Header>
<Columns>
<Box pad='small'>
<Button label='Install' onClick={props.installAct}></Button>
</Box>
<Box pad='small'>
<Button label='UnInstall' onClick={props.uninstallAct}></Button>
</Box>
<Box pad='small'>
<Button label='Start' onClick={props.startAct}></Button>
</Box>
<Box pad='small'>
<Button label='Stop' onClick={props.stopAct}></Button>
</Box>
</Columns>
</Section>
<Section>
<Header>Config</Header>
</Section>
<Section>
<Header>Cleanup</Header>
</Section>
<Footer></Footer>
</App>
)
这是主要的渲染过程(dash.js)
And this is the main render process (dash.js)
const { ipcRenderer, remote } = require('electron')
const { createStore } = require('redux')
const { composeWithDevTools } = require('redux-devtools-extension')
const { Page } = require('../jsxo/Dashboard.js')
const React = require('react');
const ReactDOM = require('react-dom')
const PropTypes = require('prop-types')
const Immutable = require('immutable')
document.addEventListener("DOMContentLoaded", render)
const page = React.createElement(Page, { serverState: 'UP',
installAct: () => alert('install'),
uninstallAct: () => alert('uninstall'),
startAct: () => alert('start'),
stopAct: () => alert('stop') })
function render() {
ReactDOM.render(page, document.getElementById('page'))
}
推荐答案
您使用的 grommet
尚未更新到新的 react
版本,因此您将从这个库中收到警告,因为它使用了来自 react
模块的已弃用的 PropTypes
.
You are using grommet
which hasn't been updated to the new react
version yet, therefore you will be getting warnings from this library because it uses the deprecated PropTypes
from react
module.
在更新依赖项之前,您无能为力.
There is nothing you can do until your dependencies are updated, too.
请注意,这已经报告,并且有一个拉取请求打开.
Note this has been already reported and there is a pull request open.
这篇关于Electron 应用程序中的 propTypes 警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!