Skip to content

Commit

Permalink
v1.1.0; blazeToReact method and guidelines for package authors
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Mar 26, 2016
1 parent c668d60 commit 5742ad1
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 50 deletions.
98 changes: 49 additions & 49 deletions .versions
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
allow-deny@1.0.2-rc.3
babel-compiler@6.5.2-rc.3
babel-runtime@0.1.6-rc.3
base64@1.0.6-rc.3
binary-heap@1.0.6-rc.3
blaze@2.1.5-rc.3
blaze-tools@1.0.6-rc.3
boilerplate-generator@1.0.6-rc.3
callback-hook@1.0.6-rc.3
check@1.1.2-rc.3
ddp@1.2.3-rc.3
ddp-client@1.2.3-rc.3
ddp-common@1.2.3-rc.3
ddp-server@1.2.4-rc.3
deps@1.0.10-rc.3
diff-sequence@1.0.3-rc.3
ecmascript@0.4.1-rc.3
ecmascript-runtime@0.2.8-rc.3
ejson@1.0.9-rc.3
gadicc:blaze-react-component@1.0.0
geojson-utils@1.0.6-rc.3
html-tools@1.0.7-rc.3
htmljs@1.0.7-rc.3
id-map@1.0.5-rc.3
jquery@1.11.6-rc.3
local-test:gadicc:blaze-react-component@1.0.0
logging@1.0.10-rc.3
meteor@1.1.12-rc.3
minimongo@1.0.12-rc.3
modules@0.5.1-rc.3
modules-runtime@0.6.1-rc.3
mongo@1.1.5-rc.3
mongo-id@1.0.2-rc.3
npm-mongo@1.4.41-rc.3
observe-sequence@1.0.9-rc.3
ordered-dict@1.0.5-rc.3
promise@0.6.4-rc.3
random@1.0.7-rc.3
reactive-var@1.0.7-rc.3
retry@1.0.5-rc.3
routepolicy@1.0.8-rc.3
spacebars@1.0.9-rc.3
spacebars-compiler@1.0.9-rc.3
tinytest@1.0.8-rc.3
tracker@1.0.11-rc.3
ui@1.0.9-rc.3
underscore@1.0.6-rc.3
webapp@1.2.6-rc.3
webapp-hashing@1.0.7-rc.3
allow-deny@1.0.2-rc.12
babel-compiler@6.5.2-rc.12
babel-runtime@0.1.6-rc.12
base64@1.0.6-rc.12
binary-heap@1.0.6-rc.12
blaze@2.1.5-rc.12
blaze-tools@1.0.6-rc.12
boilerplate-generator@1.0.6-rc.12
callback-hook@1.0.6-rc.12
check@1.1.2-rc.12
ddp@1.2.3-rc.12
ddp-client@1.2.3-rc.12
ddp-common@1.2.3-rc.12
ddp-server@1.2.4-rc.12
deps@1.0.10-rc.12
diff-sequence@1.0.3-rc.12
ecmascript@0.4.1-rc.12
ecmascript-runtime@0.2.8-rc.12
ejson@1.0.9-rc.12
gadicc:blaze-react-component@1.1.0
geojson-utils@1.0.6-rc.12
html-tools@1.0.7-rc.12
htmljs@1.0.7-rc.12
id-map@1.0.5-rc.12
jquery@1.11.6-rc.12
local-test:gadicc:blaze-react-component@1.1.0
logging@1.0.10-rc.12
meteor@1.1.12-rc.12
minimongo@1.0.12-rc.12
modules@0.5.1-rc.12
modules-runtime@0.6.1-rc.12
mongo@1.1.5-rc.12
mongo-id@1.0.2-rc.12
npm-mongo@1.4.41-rc.12
observe-sequence@1.0.9-rc.12
ordered-dict@1.0.5-rc.12
promise@0.6.5-rc.12
random@1.0.7-rc.12
reactive-var@1.0.7-rc.12
retry@1.0.5-rc.12
routepolicy@1.0.8-rc.12
spacebars@1.0.9-rc.12
spacebars-compiler@1.0.9-rc.12
tinytest@1.0.8-rc.12
tracker@1.0.11-rc.12
ui@1.0.9-rc.12
underscore@1.0.6-rc.12
webapp@1.2.6-rc.12
webapp-hashing@1.0.7-rc.12
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,53 @@ const App = () => (
);
```

## Re-exporting

```jsx
import React from 'react';
import Blaze from 'meteor/gadicc:blaze-react-component';

const atForm = (props) => <Blaze {...props} template="atForm" />;

export { atForm }; // import { atForm } from 'myPackage';
```

You can also use a default export if you prefer (and your package
has none of it's own exports, and just a single template).

## Optional and old Meteor support (no ecmascript)

### Blaze package authors, read this.

**package.js**:
```js
api.use('gadicc:blaze-react-component@1.1.0', 'client', { weak: true });
api.addFiles('somefile.js', 'client');
api.export('YourReactComponent', 'client');
```

**somefile.js**:
```js
YourReactComponent = null;
if (Package['gadicc:blaze-react-component']) {
var blazeToReact = Package['gadicc:blaze-react-component'].blazeToReact;
YourReactComponent = blazeToReact('YourBlazeTemplate');
}
```

And then, optionally, but for good practice, tell your users to:

```jsx
import { YourReactComponent } from 'meteor/yourname:yourpackage';

// And use it as expected, with attributes just like in Blaze
const App = () => {
<div>
<YourReactComponent textArg="foo" blazeArg=bar />
</div>
};
```

## Credits

* Inspired by https://github.com/gwendall/meteor-blaze-to-react/.
5 changes: 5 additions & 0 deletions blaze-react-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ class BlazeComponent extends Component {

}

blazeToReact = function(template) {
return (props) => <BlazeComponent {...props} template={template} />;
}

export { blazeToReact };
export default BlazeComponent;
3 changes: 2 additions & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'gadicc:blaze-react-component',
version: '1.0.0',
version: '1.1.0',
summary: '<Blaze template="itemsList" items={items} />',
git: 'https://github.com/gadicc/meteor-blaze-react-component',
documentation: 'README.md'
Expand All @@ -12,6 +12,7 @@ Package.onUse(function(api) {
api.use('blaze');
api.use('reactive-var');
api.mainModule('blaze-react-component.js', 'client');
api.export('blazeToReact', 'client');
});

Package.onTest(function(api) {
Expand Down

0 comments on commit 5742ad1

Please sign in to comment.