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

[3.0.0-rc.6]页面未设置任何分享时,自动默认开启了分享 #6825

Closed
vdfor opened this issue Jun 30, 2020 · 5 comments · Fixed by #6996
Closed

[3.0.0-rc.6]页面未设置任何分享时,自动默认开启了分享 #6825

vdfor opened this issue Jun 30, 2020 · 5 comments · Fixed by #6996
Assignees
Milestone

Comments

@vdfor
Copy link
Contributor

vdfor commented Jun 30, 2020

问题描述

分享被默认全局开启,在页面未调用 useShareAppMessage 时, 页面依然会分享

复现步骤

  1. yarn global add @tarojs/cli
  2. taro init
  3. 选择 typescript + 默认模板

期望行为

页面未主动开启分享时,不应默认开启分享

报错信息

系统信息

Taro CLI 3.0.0-rc.6 environment info:
System:
OS: Windows 10
Binaries:
Node: 12.16.2
Yarn: 1.22.4
npm: 6.14.4

补充信息

如果您有功能上的建议,可以提到 FeatHub

使用上的问题,欢迎在「Taro 社区」一起交流

@Arima666
Copy link

遇到相同的问题

@cncolder
Copy link
Contributor

看来 taroHooks 里需要另起一个 useEffect 专门处理 useShareAppMessage.

@Chen-jj Chen-jj added this to the 3.0.3 milestone Jul 9, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 10, 2020

现在 Page 构造器会默认注册上 onShareAppMessage 回调,但默认注册会令页面出现可分享按钮。

3.0.3 开始这里会有一个 [Breaking Change],必须给页面组件设置 enableShareAppMessage 属性为 true,告诉 Taro 这个页面需要注册 onShareAppMessage 回调。

// class component
class Index extends Component {
  static enableShareAppMessage = true

  onShareAppMessage () {}
}

// functional component
function Index {
  useShareAppMessage(() => {})
}
Index.enableShareAppMessage = true

onShareTimeline 生命周期也同理。

Chen-jj added a commit that referenced this issue Jul 10, 2020
* 增加 onAddToFavorites、onShareTimeline 页面事件 hooks
* 【Breaking】使用 onShareAppMessage,useShareAppMessage 时,必须设置页面的 enableShareAppMessage 属性为 true,#6825
@Chen-jj Chen-jj linked a pull request Jul 10, 2020 that will close this issue
15 tasks
@fjc0k
Copy link
Contributor

fjc0k commented Jul 10, 2020

现在 Page 构造器会默认注册上 onShareAppMessage 回调,但默认注册会令页面出现可分享按钮。

3.0.3 开始这里会有一个 [Breaking Change],必须给页面组件设置 enableShareAppMessage 属性为 true,告诉 Taro 这个页面需要注册 onShareAppMessage 回调。

// class component
class Index extends Component {
  static enableShareAppMessage = true

  onShareAppMessage () {}
}

// functional component
function Index {
  useShareAppMessage(() => {})
}
Index.enableShareAppMessage = true

onShareTimeline 生命周期也同理。

为啥不在 page.config.ts 里配置呢,这样的话,类型很不友好,而且跟目前的页面配置也很割裂。

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 10, 2020

有道理,应该可以做,我们再看看

Chen-jj added a commit that referenced this issue Jul 13, 2020
* 固定 lodash 版本
* 生命周期 hooks 在组件销毁时,同时销毁监听回调,fix # 6598
* 修复页面为 Class 组件,子组件使用生命周期 hooks 时不触发回调的问题。
* 增加 onAddToFavorites、onShareTimeline 页面事件 hooks
* 【Breaking】使用 onShareAppMessage,useShareAppMessage 时,必须设置页面的 enableShareAppMessage 配置为 true,#6825
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

Successfully merging a pull request may close this issue.

5 participants