Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
393 views
in Technique[技术] by (71.8m points)

javascript - 每次在reactjs中打开模式时在哪里进行api调用(Where to make api call everytime a modal opens in reactjs)

I have a modal which should be opened on a button click.

(我有一个模式,应在单击按钮时打开。)

Based on button click, it triggers an open action with an id, this id is added to the state.

(基于单击按钮,它会触发一个带有ID的打开操作,该ID被添加到状态中。)

But issue is I am not able to access this id from state before the render of modal (while modal opens).

(但是问题是,在渲染模态之前(模态打开时),我无法从状态访问此ID。)

Flow of events are like this:

(事件流是这样的:)

Button click --> dispatch openmodal action with id --> active prop turns true --> modal opens.

(单击按钮->使用id调度openmodal动作->活动道具变为true->模态打开。)

But before modal render im not able to access the id.

(但是在模态渲染之前,im无法访问ID。)

  ask by react doubt translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...