@@ -54,7 +54,7 @@ python-react provides an interface to a render server which is capable of render
5454from your python process.
5555
5656Render requests should provide a path to a JS file that exports a React component. If you want to pass
57- data to the component, you can optionally provide a second argument that will be used as the component's
57+ data to the component, you can optionally provide a second argument that will be used as the component's
5858` props ` property.
5959
6060``` python
@@ -77,10 +77,10 @@ If the object is coerced to a string, it will emit the value of the `markup` att
7777
7878Render servers are typically Node.js processes which sit alongside the python process and respond to network requests.
7979
80- To add a render server to your project, you can refer to the [ basic rendering example] ( examples/basic_rendering )
81- for a simple server that will cover most cases. The key files for the render server are:
80+ To add a render server to your project, you can refer to the [ basic rendering example] ( examples/basic_rendering )
81+ for a simple server that will cover most cases. The key files for the render server are:
8282 - [ render_server.js] ( examples/basic_rendering/render_server.js ) - the server's source code
83- - [ package.json] ( examples/basic_rendering/package.json ) - the server's dependencies, installable with
83+ - [ package.json] ( examples/basic_rendering/package.json ) - the server's dependencies, installable with
8484 [ npm] ( http://npmjs.com )
8585
8686
@@ -92,13 +92,13 @@ setup involves a build tool and a python package that can integrate it.
9292
9393The two most popular build tools are:
9494
95- - [ Webpack] ( https://webpack.github.io ) - compiles your files into browser-executable code and provides a
95+ - [ Webpack] ( https://webpack.github.io ) - compiles your files into browser-executable code and provides a
9696 variety of tools and processes which can simplify complicated workflows.
97- - [ Browserify] ( http://browserify.org/ ) - has a lot of cross-over with webpack. Is argurably the easiest of the
97+ - [ Browserify] ( http://browserify.org/ ) - has a lot of cross-over with webpack. Is argurably the easiest of the
9898 two to use, but it tends to lag behind webpack in functionality.
9999
100- For React projects, you'll find that webpack is the usual recommendation. Webpack's hot module replacement,
101- code-splitting, and a wealth of loaders are the features typically cited as being irreplaceable.
100+ For React projects, you'll find that webpack is the usual recommendation. Webpack's hot module replacement,
101+ code-splitting, and a wealth of loaders are the features typically cited as being irreplaceable.
102102[ react-hot-loader] ( https://github.com/gaearon/react-hot-loader ) is a particularly useful tool, as it allows
103103changes to your components to be streamed live into your browser.
104104
@@ -121,8 +121,8 @@ javascript worlds.
121121render_component
122122----------------
123123
124- Renders a component to its initial HTML. You can use this method to generate HTML on the server
125- and send the markup down on the initial request for faster page loads and to allow search engines
124+ Renders a component to its initial HTML. You can use this method to generate HTML on the server
125+ and send the markup down on the initial request for faster page loads and to allow search engines
126126to crawl your pages for SEO purposes.
127127
128128
@@ -147,6 +147,12 @@ render_component(
147147
148148 # An optional object which will be used instead of the default renderer
149149 renderer = None ,
150+
151+ # An optional dictionary of request header information (such as `Accept-Language`)
152+ # to pass along with the request to the render server
153+ request_headers = {
154+ ' Accept-Language' : ' da, en-gb;q=0.8, en;q=0.7'
155+ },
150156)
151157```
152158
@@ -156,25 +162,25 @@ via Django's static file finders.
156162By default, render_component relies on access to a render server that exposes an endpoint compatible
157163with [ react-render's API] ( https://github.com/markfinger/react-render ) . If you want to use a different
158164renderer, pass in an object as the ` renderer ` arg. The object should expose a ` render ` method which
159- accepts the ` path ` , ` data ` , and ` to_static_markup ` arguments.
165+ accepts the ` path ` , ` data ` , ` to_static_markup ` , and ` request_headers ` arguments.
160166
161167
162168Render server
163169-------------
164170
165171Earlier versions of this library would run the render server as a subprocess, this tended to make development
166- easier, but introduced instabilities and opaque behaviour. To avoid these issues python-react now relies on
172+ easier, but introduced instabilities and opaque behaviour. To avoid these issues python-react now relies on
167173externally managed process. While managing extra processes can add more overhead initially, it avoids pain down
168174the track.
169175
170176If you only want to run the render server in particular environments, change the ` RENDER ` setting to
171- False. When ` RENDER ` is False, the render server is not used directly, but it's wrapper will return similar
177+ False. When ` RENDER ` is False, the render server is not used directly, but it's wrapper will return similar
172178objects with the ` markup ` attribute as an empty string.
173179
174180
175181### Usage in development
176182
177- In development environments, it can be easiest to set the ` RENDER ` setting to False. This ensures that the
183+ In development environments, it can be easiest to set the ` RENDER ` setting to False. This ensures that the
178184render server will not be used, hence you only need to manage your python process.
179185
180186Be aware that the render servers provided in the examples and elsewhere rely on Node.js's module system
0 commit comments