腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
文章/答案/技术大牛
搜索
搜索
关闭
发布
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
1
回答
在
getDerivedStateFromProps
中有
两个
条件
在
我的应用程序中,
在
getDerivedStateFromProps
下,我必须像这样写
两个
条件
。static
getDerivedStateFromProps
(nextProps) { return { errors:profile.website, };
浏览 13
提问于2019-02-14
得票数 0
回答已采纳
1
回答
在
React的
getDerivedStateFromProps
中有
多个
条件
在
我的React应用程序中,我有以下代码。state = { accountDeletion: false static
getDerivedStateFromProps
(如果我删除了一个
条件
,那么另一个就可以正常工作。但总而言之,只有第一个
条件
有效。我应该如何正确地编写这段代码?
浏览 13
提问于2019-02-22
得票数 2
1
回答
如何在ReactJS中调用
getDerivedStateFromProps
内部的方法?
、
、
我
在
React类
中有
一个方法,例如someMethod()。我还有一个想要调用someMethod()的
getDerivedStateFromProps
()方法。是的,我需要在
getDerivedStateFromProps
中这样做,而不是
在
componentDidUpdate()中,例如,因为我确实在someMethod()中更改了状态。someMethod() { return 'worked';
浏览 8
提问于2019-05-04
得票数 0
回答已采纳
1
回答
为什么
getDerivedStateFromProps
会再次被调用,即使父道具没有更新?
、
我
在
React中跟踪 on LifeCycle方法&我
在
指南中修改了一个演示,有点像render - 2, 6 componentDidMount
浏览 1
提问于2019-01-19
得票数 4
回答已采纳
1
回答
响应16.X从道具获得派生状态,返回新状态.Is,可以再次更改组件内部的同一状态吗?
、
我正在使用
getderivedstatefromprops
方法查看是否发生了任何道具更改。
在
构造函数中,我添加了一个额外的状态变量来存储我的prevProps数据。稍后,我可以
在
getDerivedStateFromProps
中使用这种状态。构造函数
getDerivedStateFromProps
static
getDerivedStateFromProps
,如果再次
浏览 1
提问于2018-12-11
得票数 1
1
回答
我不能用
getDerivedStateFromProps
更新状态
在这个编辑类中,我成功地从服务器获取数据,并使用
getDerivedStateFromProps
设置状态初始值,但是当我尝试编辑任何数据时,formdata不会改变。e.preventDefault(); } static
getDerivedStateFromProps
浏览 1
提问于2020-05-25
得票数 0
回答已采纳
1
回答
如何在渲染前使用promise setState?
、
我
在
props:this.props.getProfile()
中有
promise,我想在render()之前将promise中的response值设置为状态。我尝试过使用UNSAFE_componentWillMount和
getDerivedStateFromProps
,但它总是响应一个待定的承诺。) { } });这是我对
getDerivedStateFrom
浏览 2
提问于2020-06-17
得票数 1
1
回答
Reactive16.4使
getDerivedStateFromProps
能够从状态变化中被调用。如何处理这件事?
、
、
因此,16.4“修复”了
getDerivedStateFromProps
中的一个bug,现在它在道具更改和状态更改时都会被触发。显然,这是有意的,来自于这篇文章:。然而,对我来说,挽救以前
在
该州的道具是一个重大的过头,所以我想问是否有人在处理这样的案件时做了一个程序: state= { input1: '' } static
getDerivedStateFrom
浏览 0
提问于2018-06-18
得票数 8
回答已采纳
2
回答
为什么
getDerivedStateFromProps
每次打两次电话?
allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>当道具和状态
在
16.4和更高版本时,
getDerivedStateFromProps
应该调用。
浏览 9
提问于2020-08-23
得票数 1
6
回答
为什么
在
setState之后调用
getDerivedStateFromProps
?
、
React引入了新的静态方法
getDerivedStateFromProps
(props, state),它在每个呈现方法之前都会被调用,但为什么呢?
在
属性更改之后调用它对我来说是有意义的,但在setState之后就没有了,也许我遗漏了一些东西。 我根据公司的要求创建了一个datePicker组件,组件的日期是由属性控制的。我
在
组件
中有
以下状态。(包含上个月),但
getDerivedStateFromProps
被调用,currentMonth再次与以前相同,而不是更改。我
在
state中创
浏览 2
提问于2018-06-25
得票数 36
2
回答
在
将新状态设置
在
React组件中之后调用的方法。
、
如果
getDerivedStateFromProps
返回一个新状态(从而‘设置’一个新状态(如setState),它是否会导致重新呈现?如果是,那么重呈现不会再次调用
getDerivedStateFromProps
,导致无限循环(假设
getDerivedStateFromProps
中没有检查道具的
条件
)吗?
浏览 0
提问于2019-08-28
得票数 2
回答已采纳
2
回答
我怎么知道它是
在
‘get派生状态的react.js生命周期中的初始呈现呢?
、
我使用的是react.js v16.3,我有点被
getDerivedStateFromProps
搞糊涂了。 我希望更新state,但我希望只
在
初始呈现时对状态进行特定的更改。
浏览 2
提问于2018-05-09
得票数 0
1
回答
getderivedstate函数使状态不可编辑
、
、
static
getDerivedStateFromProps
(nextProps, prevState){ email: nextProps.user &&
浏览 1
提问于2018-10-06
得票数 1
1
回答
在
getDerivedStateFromProps
中有
很多逻辑,skinny vs fat gDSFP
、
、
getDrivedStateFromProps(nextProps, prevState) {在此过程中,如果它遇到错误
条件
myFunc() return {error: true};// continue doing data manipulation
在
完成所有数据操作并返回我的组件所需的
浏览 2
提问于2018-08-22
得票数 0
1
回答
为什么静态
getDerivedStateFromProps
看不到本地组件方法?
、
但是我总是
在
getDerivedStateFromProps
react生命周期方法中为我的
两个
本地方法_startTimer和_clearTimer获取null。为什么?我的问题是如何在
getDerivedStateFromProps
中使用本地方法!请在将我的问题标记为糊涂之前仔细阅读! } static
getDerivedStateFromProps
(nextProps, prevState) {
浏览 0
提问于2018-06-14
得票数 1
2
回答
构造函数中的this.state同步调用
、
有什么方法可以
在
this.state之后执行getCurrentProfile,因为这是异步的吗?我也知道有
条件
的呈现 this.props.profile.location.city !因为它是以未定义的方式返回的,因为它是
在
Redux加载到新状态之前设置状态。
浏览 0
提问于2018-10-14
得票数 2
回答已采纳
1
回答
不良反应16.3.x新生命周期事件无效
、
、
package.json内部的正确版本,即使我做了一个console.log(React.version) getSnapshotBeforeUpdate(prevProps, prevState) { return true console.log
浏览 0
提问于2018-04-13
得票数 0
回答已采纳
5
回答
当API
在
React中可见时,
在
Modal中调用API的正确方式是什么?
、
假设我
在
一个组件
中有
一个Modal,并且我想在单击某些按钮时显示该Modal: ...<Modal visilble={this.state.visible} } }从中可以看出,componentWillReceiveProps和componentWillUpdate已被弃用,您应该在新的code.So中避免使用它们,我尝试使用静态
g
浏览 7
提问于2019-04-14
得票数 3
3
回答
在
道具上重新呈现子组件的最佳解决方案是什么?
、
在
第一次呈现时,由于componentDidMount()尚未执行,所以道具将未定义。因此,子组件得到未定义的道具,并使用它们创建状态。将数据作为来自父组件的道具传递给它们,而不设置状态(使用来自道具的数据),当父组件
在
componentDidMount(),中执行setState()时,这将导致使用新道具对子组件进行重呈现,一切正常。
浏览 2
提问于2018-11-14
得票数 0
3
回答
componentWillReceiveProps对
getDerivedStateFromProps
、
、
对我来说,componentWillReceiveProps和
getDerivedStateFromProps
到底是个微妙的问题。因为,我
在
使用
getDerivedStateFromProps
时遇到了一个问题:state = {} }) // But using this method will cause the check
浏览 4
提问于2018-08-03
得票数 11
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
区块链在金融中有五大可能应用,应用需要满足四个条件?
final在java 中有什么作用?
Excel 中有多个条件格式时,某些靠左某些靠右才能不重叠, but how?
数控剪板机在实际应用中有哪些?
云平台在物联网中有什么优势?
热门
标签
更多标签
云服务器
ICP备案
对象存储
云直播
腾讯会议
活动推荐
运营活动
广告
关闭
领券