小编Jos*_*man的帖子

如何在NavigatoriOS组件中更新初始路由的道具?

这个问题是关于围绕几个组件传递数据对象的策略.

在下面的屏幕截图中,我有一个NavigatorIOS,其中包含ListComponent的初始路由.它在Side-Menu中显示Filters组件.目前,侧面菜单已打开,过滤器可见.

我的目标是当用户更改过滤器中的内容时,我想更新ListComponent.

我可以使用单例对象来存储过滤器,但我仍然需要找到一种方法来告诉ListComponent它们已经改变了.

在此输入图像描述

var defaultFilters = {
invited: true,
joined: false,
public: true,
private: false,
}

class MainTab extends Component {

constructor( props ){
    super(props);

    this.props.filters = defaultFilters;
}

render () {

    var onFilterChange = function ( filters ) {
        console.log("filters changed");
    };

    var filtersComponent = ( <Filters filters={this.props.filters} onFilterChange={onFilterChange.bind(this)} /> );

    return (
        <SideMenu menu = { filtersComponent } touchToClose={true} …
Run Code Online (Sandbox Code Playgroud)

navigation react-native

5
推荐指数
1
解决办法
1737
查看次数

标签 统计

navigation ×1

react-native ×1