Coder Social home page Coder Social logo

react-enroute's Introduction

react-enroute's People

Contributors

farwayer avatar fson avatar oreshinya avatar tj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-enroute's Issues

No "indexRoute" equivalent

Should it exist in react-enroute? I think it should as it's quite cheap to implement, and makes components easier to write (saves use of React.Children.count):

// without indexRoute
class Index extends Component {
  render() {
    const { children } = this.props
    if (React.Children.count(children) > 0) {
      return <div><Menu /><p>Please select a category</p></div>
    } else {
      return <div><Menu />{ children }</div>
    }
  }
}

ReactDOM.render(<Router {...state}>
  <Route path="/" component={Index} /></Router>, document.querySelector('#app'))


// with indexRoute
class Index extends Component {
  render() {
    const { children } = this.props
    return <div><Menu />{ children }</div>
  }
}

class IndexHome extends Component {
  render() {
    return <p>Please select a category</p>
  }
}

ReactDOM.render(<Router {...state}>
  <Route path="/" component={Index} />
  <IndexRoute path="/" component={IndexHome} /></Router>, document.querySelector('#app'))

What do you think?

Possibly using the router-component package name?

Hey @tj. Sorry this issue is unrelated but this was the only way I saw to get in contact with you!

My name is Mark and I was working on a router package and was wondering if you would be willing to let me use the router-component npm package name?. It looks like you've created it over 5 years ago and looks like it hasn't been used. Will you be willing to allow me to use it for my project? I would be extremely grateful!

Thanks for your help!

Passing extra route props to component?

Sometimes it's really useful. For example setting screen title in react-native:

<Router>
  <Route ... title="Users" />
</Router>

Or certain configuration of component:

<Router>
  <Route ... component={List} items={users} />
</Router>

New props in Router will not re-render children with new props.

the closure of props from this function https://github.com/tj/react-enroute/blob/master/index.js#L45 seems to be causing issue and not passing new props to children on subsequent renders.

Something like below fixes the issue:

const render = (params, renderProps) => {
       const finalProps = { ...this.props, ...renderProps, location, params };
       const children = React.createElement(component, finalProps);
      return parent ? parent.render(params, { children }) : children;
}

Publish latest version?

I'm trying to use react-enroute on the server side but it seems that the npm version has this line:

localStorage.debug

and is throwing error. It seems to have been removed. Is there a plan to publish latest version to npm?

Hooks?

Do you plan including hooks "a la react-router" or in some other form?

Asynchronous route components

This router looks excellent from a first, short glance.

One big feature I couldn't find were async components. This is imo quite important to allow for code splitting with webpack like this:

<Route
  path="/hello"
  getComponent{(callback) => {
    System.import('/helloModule.jsx')
      .then((hello) => callback(null, hello));
  }} 
/>

Or the old, webpack v1 way:

<Route
  path="/hello"
  getComponent{(callback) => {
    require.ensure([], (require) => {
      callback(null, require('./helloModule.jsx'));
    });
  }} 
/>

Any plans to implement that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.