Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it necessary to use setState function to modify state values? #3

Closed
ntubiolin opened this issue May 24, 2020 · 1 comment
Closed

Comments

@ntubiolin
Copy link

Hi! Thank you for providing such a good bottender example.
I have problems when reading some state-changing code like the one below:

context.state.form.inForm = true;

According to the official bottender doc, it says that

Note: don't modify state directly using this.state.stateKey = stateValue;, it may cause unexpected behavior in the future.

I am wondering is it necessary to use setState function to modify state values? For example, context.setState({form: { ...context.form, inForm: true, },}).

@etrex
Copy link
Collaborator

etrex commented May 25, 2020

Hi ntubiolin,

Thank you for pointing out that this project is inconsistent with the document.

We recommend that you use setState to modify state values.

setState is the unique public API the Bottender provided.

we may use this API to extend more possibilities.

We do not guarantee that direct assign will work in the future.

If you want to build a conversational form in Bottender, please refer to this document: https://github.com/Yoctol/bottender-proposal-conversation.

That is our latest design for conversation.

I will rewrite this project with bottender-proposal-conversation.

@etrex etrex closed this as completed May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants