腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
搜索
关闭
文章
问答
(485)
视频
开发者手册
清单
用户
专栏
沙龙
全部问答
原创问答
Stack Exchange问答
更多筛选
回答情况:
全部
有回答
回答已采纳
提问时间:
不限
一周内
一月内
三月内
一年内
问题标签:
未找到与 相关的标签
筛选
重置
2
回答
getDerivedStateFromProps
其中之一是static
getDerivedStateFromProps
(props,state)方法。此方法本质上同步属性和状态。static
getDerivedStateFromProps
(props, state) { // these 3 properties can cha
浏览 0
修改于2018-12-05
得票数 2
回答已采纳
1
回答
getDerivedStateFromProps
() vs componentDidUpdate()
现在,我必须用
getDerivedStateFromProps
()或componentDidUpdate()替换它们。首先,我考虑使用
getDerivedStateFromProps
作为componentWillReceiveProps的替代方案,正如react-native文档所建议的那样。
getDerivedStateFromProps
是最好的地方。 因此,在
getDerivedStateFromProps
和componentDidUpdate之间使用哪一个
浏览 3
提问于2020-08-11
得票数 1
3
回答
componentWillReceiveProps对
getDerivedStateFromProps
对我来说,componentWillReceiveProps和
getDerivedStateFromProps
到底是个微妙的问题。因为,我在使用
getDerivedStateFromProps
时遇到了一个问题:state = {} }) // But using this method will cause the checkboxes to
浏览 4
提问于2018-08-03
得票数 11
回答已采纳
2
回答
反应
getDerivedStateFromProps
- setSate
如果使用的是
getDerivedStateFromProps
函数,如何设置状态?例如,我有以下内容: if (nextProps.data.imo && nextProps.data.imo问题因为它是static,所以我不能调用this.setState...。 谢谢
浏览 2
提问于2020-01-19
得票数 0
回答已采纳
2
回答
componentWillRecieveProps到
getDerivedStateFromProps
转换
我想用componentWillRecieveProps代替
getDerivedStateFromProps
。由于
getDerivedStateFromProps
不支持setState,所以我只能使用下面的代码。如何将其转换为
getDerivedStateFromProps
?
浏览 1
提问于2019-02-14
得票数 1
回答已采纳
1
回答
setState与
getDerivedStateFromProps
冲突
Component<MyComponentProps, MyComponentState> { show: true static
getDerivedStateFromProps
(props: MyComponentProps) { if ("show" in props() => this.onClick()}
浏览 0
提问于2021-03-18
得票数 0
1
回答
getDerivedStateFromProps
prevState为空
在
getDerivedStateFromProps
内部,prevState在初始加载时为null。pathname: props.location.pathname, }; static
getDerivedStateFromProps
operation here } return <SomeComponent {...this.props} /&g
浏览 17
修改于2019-02-05
得票数 0
1
回答
componentWillRecieveProps对
getDerivedStateFromProps
反对使用componentWillRecieveProps,并提倡使用
getDerivedStateFromProps
。但是,当道具被更改时,componentWillRecieveProps会被调用,但是即使在任何状态变化时,
getDerivedStateFromProps
也会被调用。 我的要求是重置状态的道具改变。
浏览 1
提问于2018-06-21
得票数 1
回答已采纳
2
回答
动画与
getDerivedStateFromProps
随着componentWillReceiveProps被弃用,替换的
getDerivedStateFromProps
返回最后的状态,我将如何随着时间的推移逐渐改变状态(即动画化的东西)与新的
getDerivedStateFromProps
Animated.timing(this.state.itemOpacity, { duration: 200, }我怎么用
getDerivedStateFromProps
浏览 4
提问于2018-06-01
得票数 2
回答已采纳
2
回答
不调用
getDerivedStateFromProps
我把
getDerivedStateFromProps
放在扩展PureComponent.的类中 this.setState({colorAnimation: this.colorAnimationStyle.toColor}) } )}
浏览 1
修改于2018-04-05
得票数 13
回答已采纳
1
回答
如何使用
getDerivedStateFromProps
/dashboard'); static
getDerivedStateFromProps
= (nextProps, prevState) => {我用
getDerivedStateFromProps
替换了componentWillRecieveProps。
浏览 7
提问于2019-01-31
得票数 0
回答已采纳
1
回答
withRouter HOC和
getDerivedStateFromProps
我尝试在一个组件中使用
getDerivedStateFromProps
,如下所示: constructorsuper(props); location: '', } export default EnhancedComponent; 并得到一个警
浏览 3
提问于2018-04-27
得票数 1
1
回答
getDerivedStateFromProps
何时清除数据?
getDerivedStateFromProps
对于组件是静态的。但今天我调试了应用程序,当我们定义它时,我在
getDerivedStateFromProps
方法中找到了其他组件数据nextProp.x。那么,当react-native将删除
getDerivedStateFromProps
数据时,为什么数据是混合的呢?
浏览 18
提问于2019-11-29
得票数 0
1
回答
shouldComponentUpdate阻止
getDerivedStateFromProps
吗?
shouldComponentUpdate()返回false,那么UNSAFE_componentWillUpdate()、render()和componentDidUpdate()将不会被开具发票 但是没有提到
getDerivedStateFromProps
我的问题是:shouldComponentUpdate()是否以与componentWillUpdate()相同的方式阻止
getDerivedStateFromProps
()的调用?
浏览 0
提问于2018-12-12
得票数 3
2
回答
getDerivedStateFromProps
返回未定义
目前首次使用
getDerivedStateFromProps
。我的代码可以工作,它可以做我想做的事情,但是我在我的控制台中收到了一个警告,这让我感到困惑,因为我的代码正在工作。警告:"
getDerivedStateFromProps
():必须返回有效的状态对象(或null)。您已返回未定义的状态对象。“是否有更好的方法来编写
getDerivedStateFromProps
以消除控制台中的警告?static
getDerivedStateFromProps
(props, state) { state.curren
浏览 3
提问于2019-09-20
得票数 2
回答已采纳
1
回答
使用Mobx误解
getDerivedStateFromProps
我对
getDerivedStateFromProps
如何与Mobx可观察对象一起工作有一些误解。我知道,Mobx会对“读取”属性(通过"dotting into")、可跟踪函数等做出反应。export default class SomeComponent extends Component {谢谢。
浏览 0
修改于2019-04-03
得票数 2
1
回答
getDerivedStateFromProps
是否未更新状态?
我有这样的场景: static
getDerivedStateFromProps
(nextProps, prevState) { console.log
getDerivedStateFromProps
不应该更新状态吗?
浏览 21
提问于2021-05-08
得票数 0
1
回答
React -
getDerivedStateFromProps
和axios
props) { this.state = { }; } 和 static
getDerivedStateFromProps
浏览 12
修改于2020-01-22
得票数 0
1
回答
在
getDerivedStateFromProps
中调用方法
this.showLockedWarning(nextProps);但是由于componentWillReceiveProps被否决了,我想使用没有此类问题的函数,据我所见,我应该有两个选项--
getDerivedStateFromProps
我不能使用componentDidUpdate,因为这会创建一个无限循环,但是从
getDerivedStateFromProps
我不能访问this关键字。在这种情况下我能做什么?
浏览 0
提问于2018-07-10
得票数 0
回答已采纳
1
回答
使用
getDerivedStateFromProps
状态到道具
但是,由于不推荐componentWillReceiveProps,所以我也试图对
getDerivedStateFromProps
做同样的事情: return {dwelling: nextProps.dwelling} return null问题是在每个呈现方法之后都调用了
getDerivedStateFromProps
浏览 1
修改于2018-11-13
得票数 1
回答已采纳
第 2 页
第 3 页
第 4 页
第 5 页
第 6 页
第 7 页
第 8 页
第 9 页
第 10 页
第 11 页
点击加载更多
领券