腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
在
React
中
调用
getDerivedStateFromProps
内部
的
异步
函数
所以我试着
在
getDerivedStateFromProps
中
调用
一个更新
函数
,但是我似乎不能在
getDerivedStateFromProps
中使用'this‘。有没有办法做到这一点?提前感谢。static
getDerivedStateFromProps
(props, state) { if(props.newValue !
浏览 43
提问于2020-05-08
得票数 1
回答已采纳
1
回答
如何使用
异步
操作从还原器
中
获取数据
、
、
这里
的
Redux新手,所以我有这样
的
代码,它分发一个
异步
操作,它使用承诺来处理请求。const mapStateToProps = (state) => { userlist: state.list_reducer,};下面是我在上面使用
的
组件this.props.fetchUserList(); listRender: true }现在可以从上面看到,我
在
fetchUse
浏览 1
提问于2018-04-21
得票数 1
2
回答
在
通过道具之前反应变异状态
、
在
react
中将道具从状态传递到其子组件之前,有没有办法先更改状态?下面是一个示例: let parsedKeyword = queryString.parse}; return ( );
在
我
的
例子
浏览 3
提问于2018-05-22
得票数 0
1
回答
使用apollo客户端设置初始状态
、
、
我正在尝试使用使用apollo客户端和graphql创建
的
prop来设置
react
状态变量
的
初始状态。我查看了生命周期方法
中
的
设置,但它仍然返回空。只有
在
render()
中
调用
函数
时,我才会得到输出。
浏览 22
提问于2019-01-25
得票数 0
回答已采纳
3
回答
在
React
中
调用
getDerivedStateFromProps
内部
的
方法
、
在
将
react
升级到16.3版本之前,我会根据属性
中
的
更改
调用
一个方法,如下所示: if(this.props.country.length== nextProps.country){ }
在
16.3版本上,componentWillReceiveProps是不安全
的<
浏览 0
提问于2018-04-05
得票数 21
回答已采纳
1
回答
React
-
getDerivedStateFromProps
和axios
、
、
我想将状态变量books设置为API
的
结果。我不能在componentDidMount
中
做这件事,因为我一开始没有token,需要它才能从API
中
获取结果。props) { this.state = { }; } })
浏览 12
提问于2020-01-22
得票数 0
1
回答
React
/Redux:等待还原剂得到道具
、
、
、
我有以下用于导航
的
组件:import { connect } from '
react
-redux'; constructor(props) { super(如果用户没有指定
的
坦克,应用程
浏览 0
提问于2019-03-11
得票数 1
回答已采纳
2
回答
为什么
getDerivedStateFromProps
每次打两次电话?
我
的
组件<iframe src="https://codesandbox.io/embed/vigorous-sun-b7pf2?allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"></iframe>当道具和状态
在
16.4和更高版本时,
getDerivedStateFromProps
应该
调用
。
浏览 9
提问于2020-08-23
得票数 1
2
回答
我怎么知道它是
在
‘get派生状态
的
react
.js生命周期中
的
初始呈现呢?
、
我使用
的
是
react
.js v16.3,我有点被
getDerivedStateFromProps
搞糊涂了。 我希望更新state,但我希望只
在
初始呈现时对状态进行特定
的
更改。
浏览 2
提问于2018-05-09
得票数 0
1
回答
如何在ReactJS
中
调用
getDerivedStateFromProps
内部
的
方法?
、
、
我
在
React
类中有一个方法,例如someMethod()。我还有一个想要
调用
someMethod()
的
getDerivedStateFromProps
()方法。是的,我需要在
getDerivedStateFromProps
中
这样做,而不是
在
componentDidUpdate()
中
,例如,因为我确实在someMethod()
中
更改了状态。someMethod() { this.setState({worke
浏览 8
提问于2019-05-04
得票数 0
回答已采纳
3
回答
setState()不能实时设置
嗨,我
在
通过道具设置组件状态时遇到了麻烦: date: '', isDailiesInformationcurrentDate}`); } 我想通过dailiesInformation
函数
设置updateCards属性,但是它比当前设置了1步,我把这个
函数
作为对c
浏览 2
提问于2019-01-14
得票数 1
回答已采纳
1
回答
哪种反应生命周期方法可以很好地替代componentWillRecieveProps?
、
我听说过
getDerivedStateFromProps
,但它没有按我所希望
的
方式工作。我有这样
的
代码: static
getDerivedStateFromProps
(props, state) { console.log这不是我需要
的
。我想要一个叫做
的
函数
,只有当新
的
道具被接收到时,它才被称为。当
内部
状态发生变化时,不应
调用
此<e
浏览 4
提问于2018-05-30
得票数 3
1
回答
React
应用程序:道具不会在外部更新
、
、
、
我有一个
React
应用程序,它可以像这样简单地进行初始化: let globalTodos = some_fetch_from_localstorage(); this.setState({ todos: this.props.todos
浏览 5
提问于2019-04-26
得票数 0
5
回答
当API
在
React
中
可见时,
在
Modal
中
调用
API
的
正确方式是什么?
、
假设我
在
一个组件中有一个Modal,并且我想在单击某些按钮时显示该Modal: ...<Modal visilble={this.state.visible} }static
getDerivedStateFromProp
浏览 7
提问于2019-04-14
得票数 3
2
回答
无法
在
getDerivedStateFromProps
中
启动
函数
、
我无法理解,为什么当我尝试
在
getTodosList
中
启动
函数
getDerivedStateFromProps
时,这个方法总是回归到我
的
TypeError - Cannot read property'getTodosList' of null
中
。另外,
在
我开始使用
getDerivedStateFromProps
之后-我
的
函数
也不会在componentDidMount
中
启动. 我
浏览 1
提问于2018-04-27
得票数 3
回答已采纳
1
回答
React
输入值
在
子组件
中
不起作用
、
子组件将在模式框
中
打开。模态框组件将包含添加和编辑用户。我已经为模式框输入传递了一些值,并在getDerivedStateFormProps生命周期钩子
中
获取了该值。最初,它将值填充到输入值。请查看以下详细信息 state.show = props.show; state.company
浏览 0
提问于2019-08-24
得票数 0
1
回答
为什么
getDerivedStateFromProps
会再次被
调用
,即使父道具没有更新?
、
我
在
React
中跟踪 on LifeCycle方法&我
在
指南中修改了一个演示,有点像 这是一个简单
的
应用程序,它使用了所有
React
的
新生命周期方法&每10秒向底部添加网格(因此等待10秒,然后查看控制台我理解
getDerivedStateFromProps
的
方式是,当父道具更改时
调用
它们,但是在这个沙箱
中
,如果您检查控制台,即使道具没有更改,它也会被
调用
。我添加了一些有用
的
浏览 1
提问于2019-01-19
得票数 4
回答已采纳
2
回答
道具变更后应何时响应
调用
AJAX请求?
、
我过去常常在道具被ComponentWillReceiveProps()更改后
调用
AJAX。== this.props.foo){ }
在
反应之后,16.3 ComponentWillReceiveProps而不是ComponentWillReceiveProps(),而是一个新
的
函数
getDerivedStateFromProps
,但是我不能更新状态
异
浏览 4
提问于2020-04-13
得票数 0
回答已采纳
5
回答
为什么我
的
React
组件渲染了两次?
、
、
、
我不知道为什么我
的
React
组件渲染了两次。因此,我从params中提取了一个电话号码,并将其保存到state
中
,以便我可以通过Firestore进行搜索。
浏览 5
提问于2018-02-18
得票数 30
6
回答
为什么
在
setState之后
调用
getDerivedStateFromProps
?
、
React
引入了新
的
静态方法
getDerivedStateFromProps
(props, state),它在每个呈现方法之前都会被
调用
,但为什么呢?
在
属性更改之后
调用
它对我来说是有意义
的
,但在setState之后就没有了,也许我遗漏了一些东西。 我根据公司
的
要求创建了一个datePicker组件,组件
的
日期是由属性控制
的
。我
在
组件中有以下状态。为此,我使用
getDerivedStateFr
浏览 2
提问于2018-06-25
得票数 36
点击加载更多
热门
标签
更多标签
云服务器
ICP备案
云直播
即时通信 IM
实时音视频
活动推荐
运营活动
广告
关闭
领券