-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/rewrite as middleware #5
Refactor/rewrite as middleware #5
Conversation
@@ -129,7 +122,7 @@ export default class RedialContext extends Component { | |||
} | |||
|
|||
reloadComponent(component) { | |||
this.load(component, this.props, true); | |||
this.load([component], this.props, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we need to do this here, redial
should take care of this for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
…asier to isolate these props and save only the previous router props
Thanks a ton, this looks awesome! 👍 Just a quick thought, what do you think about using camelCase for the new util files.
I will take a closer look at this tomorrow and play around with it a little. |
Oh absolutely, just an old habit I guess. Renaming would make it more consistent! |
This works great, awesomely done once again! 👍 I will go ahead and merge this and release it as I will add you as contributor in the |
This PR re-writes
react-router-redial
to work as a middleware. This allows it to be easily integrated with other middlewares, such asreact-router-scroll
.Notable changes
useRedial
- New function for creating a React Router middleware. Takes the same options as the earlierRedialContext
. Instead of calling<Router render={(props) => <RedialContext .../>}/>
, we now useapplyRouterMiddleware
instead:<Router render={applyRouterMiddleware(useRedial(redialOptions))}/>
path
fromRoute
rather than theComponent
. This allows us to have multiple routes handled by the same component but with different props. On the other hand, if we want to retain the properties, this is no longer possible. Perhaps we should have a way to force the redial-props key?Remaining work
Right now the
prevProps
etc doesn't work any longer. How should we handle this? Move the state down to<RedialContextContainer/>
instead?Update the documentation to highlight the new approach to render both on server and client.
Create an example mixing
useRedial
with another router middlewareAdd tests for the util functions. Also, is there a way to gracefully fail rather than throwing?
... More?