railsのアプリケーションで、react-railsを使って書き換えています。
これまでviewのhtmlの中にrubyタグを入れていたものを、
reactに書き換えたいのですが、
reactの中からrailsのcontroller上の関数を呼び出す方法を教えてください。
def index ... end def edit ... end
を書き換えて、このように書いています。
def index render component: 'Categories', props: { url: '/categories', categories: @categories} ... end def edit ... end
読み込みは全く問題なくできているのですが、
reactの中からrailsのcontrollerのedit関数を呼び出す方法を教えてください。
現在のreactコードはこちらです。
... class Categories extends React.Component{ render(){ return( {this.props.categories.map((data, i) => { <li key={i} onclick="ここでeditを呼び出したい">{data}</li> })} ) } }
あなたの回答
tips
プレビュー