0.0.5 • Published 10 years ago

react-rsk-router v0.0.5

Weekly downloads
1
License
MIT
Repository
-
Last release
10 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

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago