我尝试在React中制作我的第一个应用程序,我认为我在应用程序流程中犯了一些严重的错误,但是尝试保存它并不能使其更好。
我有我的App.ksin
val selectedColumns = if (dfRaw.columns.contains("some.field.nameOption1")) $"some.field.nameOption2" else $"some.field.nameOption2"
val dfFilter = dfRaw
.select(selectedColumns, ...)
现在只有AddComment:
select t1.launch_id, t2.user_id,
sum(t3.order_amount) as order_amount,
count(t3.order_amount) as total_orders
from Table1 as t1
join Table2 as t2 on t2.email_address_id = t1.email_address_id
left join Table3 as t3 on (t3.user_id = t2.user_id and t3.sales_transaction_date between t1.campaign_launch_date and (t1.campaign_launch_date + INTERVAL '7' DAY))
group by t1.launch_id, t2.user_id
在最新的食谱中,我有:
<LatestRecipes latestRecipes={this.state.latestRecipes} allRecipes={this.state.recipes} addComment={this.addComment}/>
这给了我错误:
无法在“历史记录”上执行“ pushState”:功能addComment()...无法克隆。
造成错误的是参数:
addComment(key, commentData)
{
console.log(key);
console.log(commentData);
}
如果我删除它,一切正常,但是我需要将函数传递给我的Recipe组件。在App.js中
<Link to={{pathname: '/recipe/' + recipe.name, state: { recipe: recipe, index: index, addComment: this.props.addComment }}}>{recipe.name}</Link>
我需要传递三个参数,即配方,索引和函数addComment()
答案 0 :(得分:0)
更改:
<Route path="/recipe/:recipe" component={Recipe}/>
收件人:
<Route path="/recipe/:recipe" render={(props) => <Recipe {...props} addComment={this.addComment}/>} />
在我的App.js中解决了它。