【发布时间】:2019-03-05 17:07:43
【问题描述】:
我正在尝试实现一个 deletePost 按钮,但我很难将它传递到我的标题组件中。这里是
export class PostScreen extends Component {
// Custom headerTitle component.
static navigationOptions = ({ navigation }) => {
const { params } = navigation.state;
return { headerTitle: <PostTitle {...params} handleDelete={this.handleDelete}/> }
};
handleDelete = async (id) => {
const { deletePost } = this.props;
const token = await AsyncStorage.getItem('token');
deletePost(token, id);
}
render() {
这似乎不是传递它的正确方法。正确的方法是什么?我在文档中找不到任何内容。
【问题讨论】:
-
您确定这是
react-native-navigation而不是react-navigation? -
@Andrew 对,是
react-navigation -
你从哪里得到 id?
标签: reactjs react-native react-navigation