PeerBoard / integration-examples

0 stars 1 forks source link

Missing await in React example #1

Open keanemind opened 1 year ago

keanemind commented 1 year ago

It seems the return value of createForum is a Promise<ForumAPI> that should be awaited. Without adding the await, componentWillUnmount runs into an error because this.forum has the wrong type.

https://github.com/PeerBoard/integration-examples/blob/5ed5450d85bb8a2eb37941bce16b5a9428f7fcd2/React/PeerBoard.jsx#L50

While we're at it, since this.forum might not exist yet when the component is being unmounted, perhaps the componentWillUnmount implementation should be this.forum?.destroy();.

sentiens commented 1 year ago

Thank you for your valuable remark, we have updated a lot in our SDK, and have not yet had time to make new examples, I apologize for the confusion.

As for the API, I think that the function should just return the result immediately without a promise, so that the developer can call destroy before everything is loaded, for example, if the user decides to leave the page, we will definitely take this into account in future versions.

sentiens commented 1 year ago

I will mark this repository as deprecated so as not to confuse anyone else and leave this issue open.

The main source of information now is the repository https://github.com/PeerBoard/core and our guides in the community https://community.peerboard.com/post/1162435747