-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Shared UX] Migrate router from kibana react to shared ux #138544
Conversation
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"outDir": "target_types", | ||
"rootDir": ".", |
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.
This might help.
"rootDir": ".", | |
"rootDir": "src", |
eeee04f
to
094b980
Compare
@rshen91 I pushed a set of changes to this branch that should fix your issues:
|
…-ref HEAD~1..HEAD --fix'
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 had a look at the code, haven't checked package-related files nor did any verification that the package builds correctly. Some comments below.
children?: ((props: RouteChildrenProps<any>) => React.ReactNode) | React.ReactNode; | ||
path?: string | string[]; | ||
exact?: boolean; | ||
sensitive?: boolean; |
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.
Should we add some explanation about what these props are?
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! Added in a31f7b1 🥳
|
||
|
||
```jsx | ||
<Route basepath="/url" /> |
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.
Not sure I understand what this example is. basepath
doesn't seem to be in RouteProps
?
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.
changed to path - good catch!
a31f7b1
<Route basepath="/url" /> | ||
``` | ||
|
||
This component removes the need for manual calls to `useExecutionContext` and should be removed. |
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.
*they should be removed?
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.
Thank you! a31f7b1
import { Route } from './router'; | ||
|
||
describe('Route', () => { | ||
test('renders', () => { |
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 we add a more extensive test suite? Given that the render logic depends on a lot of props, would be nice to test some of those scenarios.
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've added some of the react dom route props in the test suite - let me know what you think. I think for testing exact
, sensitive
and strict
it might involve an integration test?
/> | ||
); | ||
} | ||
if (typeof children === 'function') { |
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 we put this and previous "if" in one if statement, cause they seem to be doing exactly the same thing?
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.
Wait I could use some clarification - the first if is checking for a render and then rendering props whereas the if on line 54 is checking for the typeof children to be a function and if it is then is using the function from children to render the props (vs render itself). Let me know what I'm missing thanks!
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.
So the body of the if-statement is exactly the same in both cases. You can do something like:
if (typeof children === 'function' || render) {
const renderFunc = (typeof children === 'function') ? children : render;
return (
<ReactRouterRoute
{...rest}
render={(props) => (
<>
<MatchPropagator />
{renderFunc(props)}
</>
)}
/>
);
}
}
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.
Thank you for the help! - 0556d16
…-ref HEAD~1..HEAD --fix'
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.
Nice one! Code review only
expect(example).toMatchSnapshot(); | ||
}); | ||
|
||
test('render prop renders', () => { |
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.
nice!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: cc @rshen91 |
Summary
Building from discussion in #132629, this PR aims to refactor the kibana router and bring it into shared ux. #131805 refactored the router in kibana react and this PR will migrate it to shared ux.
Next Steps for Future PRs
react-router-dom
usage throughout kibanakibana_react_router
Checklist
Delete any items that are not applicable to this PR.
For maintainers