Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 从链接获取道具对象_React Native_React Router Native - Fatal编程技术网

React native 从链接获取道具对象

React native 从链接获取道具对象,react-native,react-router-native,React Native,React Router Native,如何做到这一点?例如,我发现: <Link to={{pathname: "/dialog", state: { detail: message }}}> text </Link> 文本 但是如果我想显示这个.props.location.state,那么就写未定义的传递参数 Configure your route path to accept named parameters (:id): <Route path='/route/:id' exact c

如何做到这一点?例如,我发现:

<Link to={{pathname: "/dialog", state: { detail: message }}}>
text
</Link>

文本
但是如果我想显示这个.props.location.state,那么就写未定义的

传递参数

Configure your route path to accept named parameters (:id):

<Route path='/route/:id' exact component={MyComponent} />
Then you can pass URL parameters such as IDs in your link to:

<Link to={`route/foo`}>My route</Link>
You can access the parameter within your component via the match object:

const {id} = props.match.params

console.log(id) // "foo"
配置路由路径以接受命名参数(:id):
然后,您可以将URL参数(如链接中的ID)传递到:
我的路线
您可以通过匹配对象访问组件中的参数:
const{id}=props.match.params
console.log(id)/“foo”
}/>
,消息是对象,但即使字符串也不传递参数。