appsmithorg / appsmithorg/appsmith-docs

[Docs]: Provide best practices in using Widget's selectedValue property or pass parameters to the Query/API as alternative to storeValue

Đang mở
#602 1 bình luận 0 reaction 1 người được giao Được giao cho @harshilp24 Xem trên GitHub
A-Force Documentation medium Ready for Doc Team User Education Pod
Ngôn ngữ chính
MDX
Star
97
Fork
280
Merge trung bình
4 giờ 32 phút
Pull request đã merge (30 ngày)
8

Mô tả

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Documentation Link

https://docs.appsmith.com/reference/appsmith-framework/query-object

### Discord/slack/intercom Link

_No response_

### Describe the problem

Many users use the storeValue function unnecessarily in many places.
There have been scenarios where when a widget like Select button is updated, they call the storeValue function in onOptionChange first, and then immediately run an API that is using the stored value.
storeValue is an expensive function and needs to be used only when needed. It would also take time, so calling an API immediately after would not have the latest value of the store updated by then. You would have to correctly use async/await to avoid running an API/Query with outdated values.

And most likely they wouldn't be needing the stored value for any other case except to run the Query whenever a CTA is triggered.

### Describe the improvement

This can clearly be avoided by educating the user to directly use the widget's selected value.
Eg JSObject1.formData.id or Select1.selectedOptionValue or DatePicker1.formattedData, etc

Another way to do it, would be to retrieve these values from the above mentioned widgets and pass it as a query-object to the API/Query. This can be accessed inside the queries as this.params, hence allowing the API to be generic without being dependant on any specific widget value.

Any app that is using storeValue function this way to achieve these workflows, would most likely have a lot of them. And the performance of the app can increase significantly by using the above mentioned alternatives wherever possible.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.