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
162 views
in Technique[技术] by (71.8m points)

reactjs - Is there a way to have a function where given some arguments, it returns state and/or actions?

I am currently building a simple web element editor with React using Redux. It works as it should work with a small number of elements. I can see though that when the number of elements gets on a two digit scale, it will be frustrating to organize and maintain. The reason is because I have to pass [IDs and names (local to the function data), State, Actions] to the function I call which in turn filters the arguments and calls other functions with the right arguments etc. I think it is more ifs than it is needed. Can it be done with a function where I can have all the state and the actions, pass it some arguments, choose the correct path and done?

I do not think that providing code will help with this question, you would have see my file system as well to have the whole picture.

I am a junior developer so please forgive me if this is a stupid question or similar. Thank you in advance!

question from:https://stackoverflow.com/questions/65926206/is-there-a-way-to-have-a-function-where-given-some-arguments-it-returns-state-a

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

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

1.4m articles

1.4m replys

5 comments

57.0k users

...