-
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #689 from shakacode/justin800/allow-router-result-…
…to-return-html-string Added property renderedHtml to return gen func
- Loading branch information
Showing
19 changed files
with
203 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
node_package/src/isCreateReactElementResultNonReactComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default function isResultNonReactComponent(reactElementOrRouterResult) { | ||
return !!( | ||
reactElementOrRouterResult.renderedHtml || | ||
reactElementOrRouterResult.redirectLocation || | ||
reactElementOrRouterResult.error); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
rails: REACT_ON_RAILS_ENV=HOT rails s -b 0.0.0.0 | ||
|
||
# Build client assets, watching for changes. | ||
rails-client-assets: rm app/assets/webpack/* || true && npm run build:dev:client | ||
|
||
# Build server assets, watching for changes. Remove if not server rendering. | ||
rails-server-assets: npm run build:dev:server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<%= render "header" %> | ||
|
||
<%= react_component("RenderedHtml", prerender: true, props: { hello: "world" }, trace: true) %> | ||
|
||
<hr/> | ||
|
||
This page demonstrates a component that returns renderToString on the server side. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
const EchoProps = (props) => ( | ||
<div> | ||
Props: {JSON.stringify(props)} | ||
</div> | ||
); | ||
|
||
export default EchoProps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Top level component for simple client side only rendering | ||
import React from 'react'; | ||
|
||
import EchoProps from '../components/EchoProps'; | ||
|
||
/* | ||
* Export a function that takes the props and returns a ReactComponent. | ||
* This is used for the client rendering hook after the page html is rendered. | ||
* React will see that the state is the same and not do anything. | ||
* Note, this is imported as "HelloWorldApp" by "clientRegistration.jsx" | ||
* | ||
* Note, this is a fictional example, as you'd only use a generator function if you wanted to run | ||
* some extra code, such as setting up Redux and React-Router. | ||
*/ | ||
export default (props, railsContext) => ( | ||
<EchoProps {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Top level component for simple client side only rendering | ||
import React from 'react'; | ||
import { renderToString } from 'react-dom/server' | ||
import EchoProps from '../components/EchoProps'; | ||
|
||
/* | ||
* Export a function that takes the props and returns an object with { renderedHtml } | ||
* Note, this is imported as "RenderedHtml" by "serverRegistration.jsx" | ||
* | ||
* Note, this is a fictional example, as you'd only use a generator function if you wanted to run | ||
* some extra code, such as setting up Redux and React-Router. | ||
* | ||
* And the use of renderToString would probably be done with react-router v4 | ||
* | ||
*/ | ||
export default (props, railsContext) => { | ||
const renderedHtml = renderToString( | ||
<EchoProps {...props} /> | ||
); | ||
return { renderedHtml }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters