How can I use a ReactComponent as a Layout ?
See original GitHub issueif i write yield like this in application.html.slim
, the other components will render out of the layout component
doctype html
html
head
title
| Quiver
= javascript_pack_tag 'application'
= csrf_meta_tags
body
= react_component('ApplicationLayout',{logo: asset_path('logo'))
= yield
Here is the description with a picture .
so ,is anybody can teach me how to do that? thanks … 😦
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Create Your Own Layout Component in React
The layout component is a component used to share a common section across multiple pages. ... class Footer extends React.Component {
Read more >Layout Component and why we use it in React
In this blog post I will go through Layout Component - an ... In the main App.js file we import Layout and wrap...
Read more >Design Page Layout and Styling in React Application — Part 3
First we will import the styled library from styled-components in every component. We'll define some element styles as variables then we'll use ......
Read more >Create a layout component using React - Edward Beazer Blog
Create a layout component using React. Quick and easy way to stop importing header/nav/footer components in routes. Wed, 05 Sep 2018.
Read more >Building a Dynamic Layout in React - YouTube
After completing this React tutorial, you'll be able to: - Model a React component that can take a collection of child components.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I didn’t describe it clearly . The requirements and descriptions are :
application.html.slim
.It’s something like this :
In
application.html.slim
.In Rails Controller
FooController.rb
In
app/views/foos/bar.html.slim
:And the Component looks like :
AppLayout.js
If i use the way u suggest , like :
It means that the layout is simple HTML TAGS but not react components . Also means that I can not use AntDesign’s Layout components … 😦
Or . I have to import AppLayout Components in every Component Like This :
😦
Maybe it is the problem of my project-structure-design . It’s a very old and large project , hard to refactor .
I think U are right . The react-rails gem is simple and easy to use . I have tried the rails_on_react , it’s too complex for me .
I will keep importing AppLayout Components in every Component to keep development schedule until I find A better way . Or refactor the structure-design .
Thanks .
@qxchen6
“Simplest” though definitely not best practice:
Create a layout ReactComponent which renders passed in HTML in a prop as dangerouslySetInnerHTML.
Again, not best practice.
On second thought,
yield
might not work as is. If it doesn’t tryrender_to_string(partial: "yield")
then have aapp/views/application/_yield.html.erb
which just containsyield
.