我想使用HOME SCREEN中的搜索栏来搜索tabview类MENU CLASS中的数据。有人知道如何从主屏幕在菜单屏幕中调用该功能吗?以及如何将值(属性)从主屏幕传递到菜单屏幕?
MenuScreen
withHandlers({
setData: props => async () => {
let drink = await props.drinkStore.getDrink()
props.setRecipe(JSON.parse(drink))
},
print: props=>()=>{
console.log("print");
console.log(props.search);
}
主屏幕
const enhance = compose(
inject('authStore'),
injectIntl,
withState('recipe', 'setRecipe', recipe),
withState('search','setSearch'),
withHandlers({
handleNavigation: props => (route, orderId) => {
props.navigation.navigate(route, orderId)
}
}),
withHandlers({
searchFilter: props => (text) => {
props.setSearch(text)
console.log("search"+props.search);
props.print();
}
})
);
export default enhance(props => (
<Container>
<LinearGradient colors={['#e2dcd3', '#B5AE9E']} style={{ flex: 1, paddingTop: 30 }}>
<SearchBar >
<TextInput style={{ width: '90%' }} onChangeText={(text) => props.searchFilter(text)}></TextInput>
<Image source={iconSearch} />
</SearchBar>
<TabView {...props}
views={[
{
title: 'Menu',
view: <MenuScreen {...props} key="1" activeSwipeTab={0} />
},
{
title: 'Favourite',
view: <FavouriteScreen {...props} key="2" activeSwipeTab={1} />
}
]}
scrollEnabled={false}
indicatorColor={colors.darkBrown}
/>
</LinearGradient>
));