-
Notifications
You must be signed in to change notification settings - Fork 55
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
feat(cmf): route onEnter/onLeave with dispatch #1082
feat(cmf): route onEnter/onLeave with dispatch #1082
Conversation
output/cmf.eslint.txt
Outdated
|
||
✖ 8 problems (3 errors, 5 warnings) | ||
/home/travis/build/Talend/ui/packages/cmf/src/UIRouter.js | ||
27:78 error 'dispatch' is missing in props validation react/prop-types |
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.
can you clean the lint errors ?
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.
Oh, I haven't turned on eslint on my new computer, sorry for that
output/containers.eslint.txt
Outdated
> eslint --config ../../.eslintrc src | ||
|
||
The react/require-extension rule is deprecated. Please use the import/extensions rule from eslint-plugin-import instead. | ||
|
||
/home/travis/build/Talend/ui/packages/containers/src/ActionSplitDropdown/ActionSplitDropdown.test.js | ||
4:10 error 'ActionSplitDropdown' is defined but never used no-unused-vars | ||
|
||
/home/travis/build/Talend/ui/packages/containers/src/DeleteResource/deleteResource.sagas.js | ||
106:4 warning Unexpected console statement no-console |
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.
can you remove the console
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.
WTF Oo, haven't touched this file
I'll fix it
1 similar comment
const routes = api.route.getRoutesFromSettings(context, props.routes); | ||
if (routes.path === '/' && !!routes.component) { | ||
return (<BaseRouter routes={routes} history={props.history} />); | ||
const routes = api.route.getRoutesFromSettings(context, props.routes, props.dispatch); |
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.
The UIRouter is just connected, not cmfConnected so you don't have props.dispatch.
You may have it from the context if you add the store to it
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.
Yes but it's ok IMO. The entry point to cmf store is still redux, so dispatching an action from react-redux is the same as dispatching an action from cmf redux.
packages/cmf/src/settings.md
Outdated
{ | ||
"routes": { | ||
"path": "/", | ||
... |
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.
stop using three dots, looks weird
packages/cmf/src/settings.md
Outdated
@@ -130,3 +130,49 @@ CMF uses [React router](https://github.com/ReactTraining/react-router). The defi | |||
} | |||
} | |||
``` | |||
|
|||
You can use onEnter/onLeave lifecycle hooks. To do that, you need to |
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.
You can use onEnter/onLeave lifecycle hooks. To do that, you need to:
packages/cmf/src/settings.md
Outdated
|
||
You can use onEnter/onLeave lifecycle hooks. To do that, you need to | ||
* register a route function in CMF registry | ||
* add the route function id in your route setting |
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.
dd the route function id in your route settings
What is the problem this PR is trying to solve?
This is not possible to dispatch an action in cmf router onEnter/onLeave hook.
What is the chosen solution to this problem?
Reshape the onEnter/onLeave functions to pass redux dispatch function
Please check if the PR fulfills these requirements
[x] This PR introduces a breaking change
The onEnter/onLeave functions arguments have changed