rwr-react_router 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.travis.yml +2 -1
 - data/CHANGELOG.md +6 -1
 - data/README.md +18 -0
 - data/Rakefile +1 -1
 - data/js/src/index.js +5 -3
 - data/js/src/version.js +1 -1
 - data/js/test/index.js +3 -2
 - data/lib/react_webpack_rails/react_router_integration/version.rb +1 -1
 - data/lib/react_webpack_rails/react_router_integration/view_helpers.rb +2 -2
 - data/package.json +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1a3833f3d96ddf37b3fbb317b63d5792732242f3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: cb17d557a4919ff1f8af7922287e84b327577cb3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: af6cc16e5dab4b9bfe781b7538ad14aab6896b0efcf37663447d5abd969406ee6b8d5090326bc7df8b33c6ce2175cd178f5095a86b617ce1eae8c82b6e91f07d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3326daef28a1425b97d67178dfb947139d7ef39e6dc92ba36d41baf70af7f21e92c58c66b7501fd56098cc3820a8d79eda3d90c0ef2186dbb0cecd1fcf3f09eb
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -34,6 +34,24 @@ RWRReactRouter.register('MyRouter', MyRouter); 
     | 
|
| 
       34 
34 
     | 
    
         
             
            <%= react_router('MyRouter') %>
         
     | 
| 
       35 
35 
     | 
    
         
             
            ```
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
      
 37 
     | 
    
         
            +
            ### Passing props to router.
         
     | 
| 
      
 38 
     | 
    
         
            +
            `RWRReactRouter.register` accepts both - react-router instance and function.
         
     | 
| 
      
 39 
     | 
    
         
            +
            When registering function instead of react-router instance, integration will take props (if any were passed to `react_router` helper) and will pass them to given function as first argument. This way you can pass them down to router of you choice:
         
     | 
| 
      
 40 
     | 
    
         
            +
            ```js
         
     | 
| 
      
 41 
     | 
    
         
            +
            function RouterWithProps(props) {
         
     | 
| 
      
 42 
     | 
    
         
            +
              return (
         
     | 
| 
      
 43 
     | 
    
         
            +
                <Router history={browserHistory}>
         
     | 
| 
      
 44 
     | 
    
         
            +
                  <Route path="/with_props" component={App} yourName={props}>
         
     | 
| 
      
 45 
     | 
    
         
            +
                    <Route path="about" component={About}/>
         
     | 
| 
      
 46 
     | 
    
         
            +
                    <Route path="home" component={Home}/>
         
     | 
| 
      
 47 
     | 
    
         
            +
                  </Route>
         
     | 
| 
      
 48 
     | 
    
         
            +
                </Router>
         
     | 
| 
      
 49 
     | 
    
         
            +
              );
         
     | 
| 
      
 50 
     | 
    
         
            +
            }
         
     | 
| 
      
 51 
     | 
    
         
            +
            ```
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            Props passed to route will be available under `props.route.yourName`.
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
       37 
55 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       38 
56 
     | 
    
         
             
            ## Issues
         
     | 
| 
       39 
57 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -44,6 +44,6 @@ namespace :setup do 
     | 
|
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
              desc 'Prepare rails4 test app dependencies'
         
     | 
| 
       46 
46 
     | 
    
         
             
              task :rails4 do
         
     | 
| 
       47 
     | 
    
         
            -
                sh %Q(npm install && cd spec/rails4_dummy_app && npm install && bundle install)
         
     | 
| 
      
 47 
     | 
    
         
            +
                sh %Q(npm install && cd spec/rails4_dummy_app && rm -rf node_modules/rwr-react-router && npm install && bundle install)
         
     | 
| 
       48 
48 
     | 
    
         
             
              end
         
     | 
| 
       49 
49 
     | 
    
         
             
            end
         
     | 
    
        data/js/src/index.js
    CHANGED
    
    | 
         @@ -19,7 +19,7 @@ class ReactRouterIntegration { 
     | 
|
| 
       19 
19 
     | 
    
         
             
                return this.routers[name];
         
     | 
| 
       20 
20 
     | 
    
         
             
              }
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
              render(name, node) {
         
     | 
| 
      
 22 
     | 
    
         
            +
              render(name, node, props = {}) {
         
     | 
| 
       23 
23 
     | 
    
         
             
                if (this.enabled === true) {
         
     | 
| 
       24 
24 
     | 
    
         
             
                  throw new Error(
         
     | 
| 
       25 
25 
     | 
    
         
             
                    `Error when rendering ${name}\n
         
     | 
| 
         @@ -27,7 +27,9 @@ class ReactRouterIntegration { 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  );
         
     | 
| 
       28 
28 
     | 
    
         
             
                }
         
     | 
| 
       29 
29 
     | 
    
         
             
                this.enabled = true;
         
     | 
| 
       30 
     | 
    
         
            -
                 
     | 
| 
      
 30 
     | 
    
         
            +
                const constructor = this.get(name);
         
     | 
| 
      
 31 
     | 
    
         
            +
                const router = typeof(constructor) === 'function' ? constructor(props) : constructor;
         
     | 
| 
      
 32 
     | 
    
         
            +
                ReactDOM.render(router, node);
         
     | 
| 
       31 
33 
     | 
    
         
             
              }
         
     | 
| 
       32 
34 
     | 
    
         | 
| 
       33 
35 
     | 
    
         
             
              unmount(node) {
         
     | 
| 
         @@ -38,7 +40,7 @@ class ReactRouterIntegration { 
     | 
|
| 
       38 
40 
     | 
    
         
             
              get integrationWrapper() {
         
     | 
| 
       39 
41 
     | 
    
         
             
                return {
         
     | 
| 
       40 
42 
     | 
    
         
             
                  mount: function _mount(node, payload) {
         
     | 
| 
       41 
     | 
    
         
            -
                    this.render(payload.name, node);
         
     | 
| 
      
 43 
     | 
    
         
            +
                    this.render(payload.name, node, payload.props);
         
     | 
| 
       42 
44 
     | 
    
         
             
                  }.bind(this),
         
     | 
| 
       43 
45 
     | 
    
         | 
| 
       44 
46 
     | 
    
         
             
                  unmount: function _unmount(node) {
         
     | 
    
        data/js/src/version.js
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            export default '0. 
     | 
| 
      
 1 
     | 
    
         
            +
            export default '0.2.0';
         
     | 
    
        data/js/test/index.js
    CHANGED
    
    | 
         @@ -115,13 +115,14 @@ describe('RWRReactRouter', function () { 
     | 
|
| 
       115 
115 
     | 
    
         
             
                  it('calls renderComponent', function () {
         
     | 
| 
       116 
116 
     | 
    
         
             
                    const mountSpy = spyOn(subject, 'render');
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
                    const payload = { name: 'routerName' };
         
     | 
| 
      
 118 
     | 
    
         
            +
                    const payload = { name: 'routerName', props: { foo: 'bar' } };
         
     | 
| 
       119 
119 
     | 
    
         
             
                    subject.integrationWrapper.mount(node, payload);
         
     | 
| 
       120 
120 
     | 
    
         | 
| 
       121 
121 
     | 
    
         
             
                    expect(mountSpy.calls.length).toEqual(1);
         
     | 
| 
       122 
122 
     | 
    
         
             
                    expect(mountSpy).toHaveBeenCalledWith(
         
     | 
| 
       123 
123 
     | 
    
         
             
                      'routerName',
         
     | 
| 
       124 
     | 
    
         
            -
                      { nodeType: 1, nodeName: 'DIV' }
         
     | 
| 
      
 124 
     | 
    
         
            +
                      { nodeType: 1, nodeName: 'DIV' },
         
     | 
| 
      
 125 
     | 
    
         
            +
                      { foo: 'bar' }
         
     | 
| 
       125 
126 
     | 
    
         
             
                    );
         
     | 
| 
       126 
127 
     | 
    
         
             
                  });
         
     | 
| 
       127 
128 
     | 
    
         
             
                });
         
     | 
    
        data/package.json
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rwr-react_router
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Rafał Gawlik
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-03-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     |