我试图弄清楚如何使用其他道具克隆现有元素.
以供参考:
this.mainContent = <Hello message="Hello world!" />
Run Code Online (Sandbox Code Playgroud)
我试图做类似的事情
React.createElement(this.mainContent, Object.assign({},
this.mainContent.props, { anotherMessage: "nice to meet ya!" }));
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我怎么做到这一点?
我正在使用react-router-redux(https://github.com/ReactTraining/react-router/tree/master/packages/react-router-redux)
安装
npm install --save react-router-redux@next
Run Code Online (Sandbox Code Playgroud)
像这样实现:
<Route path='/resource/:id' component={Resource}/>
Run Code Online (Sandbox Code Playgroud)
我正在尝试访问容器中id的参数,如下所示:
const mapStateToProps = (state, ownProps) => {
console.log(ownProps)
return {...state.resource, id: ownProps.params.id}
}
Run Code Online (Sandbox Code Playgroud)
如react-router-redux文档中所示.
我收到一个错误,说明ownProps.params是未定义的.这样可行:
const mapStateToProps = (state, ownProps) => {
return {...state.resource, id: ownProps.match.params.id}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我记录ownProps时,我发现ownProps.match.params.id包含我需要的id.
这是实施中的变化还是我实施了错误的路线?谢谢
我在连接到多个数据库的 Flask 应用程序中使用 sqlalchemy,使用此处所示的绑定。我想在非主数据库之一上执行原始 SQL 查询。
\n\n我正在尝试使用session.execute,如此处所示,但它针对主数据库执行。API 文档声明您可以使用参数:“bind \xe2\x80\x93 用作绑定的可选引擎”。如何访问和指定非主数据库的绑定并调用 session.execute 来执行该数据库的查询?
\n\n或者,还有其他方法可以解决这个问题吗?
\n