diff --git a/__tests__/__snapshots__/createApiWithCss.test.js.snap b/__tests__/__snapshots__/createApiWithCss.test.js.snap
index 985dadc..cd7f450 100644
--- a/__tests__/__snapshots__/createApiWithCss.test.js.snap
+++ b/__tests__/__snapshots__/createApiWithCss.test.js.snap
@@ -127,6 +127,38 @@ Object {
}
`;
+exports[`unit tests passes additional props through the created component APIs 1`] = `
+
+
+
+
+`;
+
+exports[`unit tests passes additional props through the created component APIs 2`] = `
+
+
+
+
+`;
+
exports[`unit tests stylesAsString() 1`] = `
"/Users/jamesgillmore/App/build/main.css- the css!
diff --git a/__tests__/createApiWithCss.test.js b/__tests__/createApiWithCss.test.js
index 05ef791..43a3bac 100644
--- a/__tests__/createApiWithCss.test.js
+++ b/__tests__/createApiWithCss.test.js
@@ -126,4 +126,13 @@ describe('unit tests', () => {
const hash = createCssHash(stats) /*? $ */
expect(hash).toMatchSnapshot()
})
+
+ it('passes additional props through the created component APIs', () => {
+ const files = ['0.js', '0.css', 'main.js', 'main.css']
+ const filesForCss = ['main.js', 'main.css', '0.js', '0.css']
+ const api = createApiWithCss(files, filesForCss, stats, outputPath) /*? $ */
+
+ expect(api.Js({ foo: 'bar' }) /*? $.props.children */).toMatchSnapshot()
+ expect(api.Styles({ foo: 'bar' }) /*? $.props.children */).toMatchSnapshot()
+ })
})
diff --git a/src/createApiWithCss.js b/src/createApiWithCss.js
index b85375c..332843b 100644
--- a/src/createApiWithCss.js
+++ b/src/createApiWithCss.js
@@ -48,22 +48,28 @@ export default (
const api = {
// 1) Use as React components using ReactDOM.renderToStaticMarkup, eg:
//
- Js: () => (
+ Js: props => (
- {scripts.map((file, key) => (
+ {scripts.map(file => (
))}
),
- Styles: () => (
+ Styles: props => (
- {stylesheets.map((file, key) => (
-
+ {stylesheets.map(file => (
+
))}
),
@@ -91,19 +97,17 @@ export default (
// Use as a React component () or a string (`${css}`):
// NOTE: during development, HMR requires stylesheets.
Css: () =>
- DEV ? (
- api.Styles()
- ) : (
-
+ (DEV
+ ? api.Styles()
+ :
-
- ),
+ ),
css: {
toString: () =>
// lazy-loaded in case not used
- DEV
+ (DEV
? api.styles.toString()
- : ``
+ : ``)
},
// 4) names of files without publicPath or outputPath prefixed:
@@ -126,9 +130,7 @@ export default (
),
cssHash: {
toString: () =>
- ``
+ ``
}
}