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

Search-bar onChange bug #739

Closed
HengCC opened this issue Jan 17, 2017 · 3 comments
Closed

Search-bar onChange bug #739

HengCC opened this issue Jan 17, 2017 · 3 comments
Assignees
Labels

Comments

@HengCC
Copy link

HengCC commented Jan 17, 2017

**原生的TextInput也支持onChange, 按照现在的写法,在render的时候没有过滤掉onChange事件. 会导致在某些情况下(比如一个组件中仅仅包含了一个search-bar和一个展示框. 展示框展示的是search-bar中onChange的值, 这时候这个展示框渲染值的速度无比的慢. 测试IOS和Android都是这样)组件渲染特别的慢.

因为search-bar暴露出去的onChange和原生的重叠了.导致onChangeText 和 onChange都执行的是一个方法..

解决办法有2个.第一个修改search-bar暴露出去的onChange->onValueChange,这个是目前的解决方案. 另外个办法就是过滤掉onChange.

但是这样原生的onChange就无法支持了.**

修改方案

@warmhug warmhug added the RN label Jan 18, 2017
@silentcloud
Copy link
Contributor

silentcloud commented Jan 20, 2017

@HengCC 你是指的,下面这样用有问题么?

<SearchBar  />
<TextInput />

能否贴一下你的代码

@HengCC
Copy link
Author

HengCC commented Jan 20, 2017

<SearchBar onChange={(e) => { dispatch({ type: "accountTab/test", value: e }) } } /> <Text>{value}</Text>

reducer:

reducers: { test(state, action) { return { ...state, value: action.value } } }

@silentcloud 不要开调试模式,调试模式渲染速度正常. 非调试模式下{value} 这个基本在searchbar中输入的值大概3秒后才能出来

@paranoidjk
Copy link
Contributor

我来fix吧,最初设计意图可能是SearchBar对外暴露的API统一是onChange(value)

但对应RN的是onChangeText(value)onChange(e)

所以在 这里 做了一个转换,但在这里 没有把onChange过滤掉,导致每次输入,RN的onChangeTextonChange同时执行

@paranoidjk paranoidjk assigned paranoidjk and unassigned silentcloud Feb 19, 2017
@paranoidjk paranoidjk added the bug label Feb 19, 2017
@paranoidjk paranoidjk changed the title Search-bar onClick bug Search-bar onChange bug Feb 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants