0.0.5 • Published 8 years ago

react-rsk-router v0.0.5

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

React RSK-Router

Declarative stateful react component router

import React from 'react';
import {route} from 'rsk-router';
 
class SomeReactComponent extends React.Component {
    constructor(props) {
        super(props);
        // Router requires some default states (only strings are allowed). 
        this.state = {
            someState: 'defaultValue',
            id: 'DfeEr1a3',
            zoom: '10%',
            path: '/path/to/some/file/or/folder'
        }
    }
    render() {
        // Some presentation code here 
    }
}
 
SomeReactComponent.stateRoutes = ['someState', 'id']; // States that will be bind to url`s route in said order 
SomeReactComponent.stateQuery = ['zoom', 'path']; // States that woll be bind to url`s query params 
 
export default route(SomeReactComponent);

On initial load code above will redirect you to your.domain/#/defaultValue/DfeEr1a3?zoom=10%&path=/path/to/some/file/or/folder (Only hash history is supported by now). And from now you can change url and it will effect corresponding component`s state and vice versa, mutating state of bind component will cause the appropriate change of url route or query.

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago