kails icon indicating copy to clipboard operation
kails copied to clipboard

react components multiple-use

Open geniuszty opened this issue 7 years ago • 1 comments

I've no idea about how to import two or more same react component objects into one pug template ,with different props and being rendered with different html ids.

geniuszty avatar Dec 22 '17 06:12 geniuszty

Controller:

const locals = {
   component1: await renderToString(<Articles articles={ articles } />),
   component2: await renderToString(<Articles articles={ articles2 } />)
}
await ctx.render('home/index', locals);

View:

#articles
    !=component1
#articles1
  !=component1

JS:

ReactDOM.render(
  <Articles articles={ articles } />,
  document.getElementById('articles')
);
ReactDOM.render(
  <Articles articles={ articles2 } />,
  document.getElementById('articles1')
);

embbnux avatar Jan 29 '18 13:01 embbnux