Skip to content
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

Fix/warnings in component: UValidatorComponent #85

Merged
merged 3 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/components/UMenu/UMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react'
import Menu from '@material-ui/core/Menu'

/**
* UMenu encapsulates Menu component from material ui
* Original component was written using class which throws a warning :
* *****
* Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
* Check the render method of `ForwardRef(Menu)`.
* *****
* For these scenarios, using React.forwardRef is recommended.(e.g .https://github.com/mui-org/material-ui/issues/15903)
* Another solution is wrapping the children withing a container(div). This one seems to be
* working for the current version
*/
const UMenu = React.forwardRef((props, ref) => {
return (
<Menu ref={ref} {...props}>
<div>{props.children}</div>
</Menu>
)
})

export default UMenu
14 changes: 14 additions & 0 deletions src/components/UMenu/UMenu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
```jsx
import React from 'react'
// import Menu from '@material-ui/core/Menu'

// export default UMenu = React.forwardRef((props, ref) => {

// return (
;<Menu ref={ref} {...props}>
<div>{props.children}</div>
</Menu>

// )
// })
```
1 change: 1 addition & 0 deletions src/components/UMenu/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './UMenu'
2 changes: 1 addition & 1 deletion src/components/UValidatorComponent/UValidatorComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ UValidatorComponent.propTypes = {
/** Allow to use required validator in any validation trigger, not only form submit. */
withRequiredValidator: PropTypes.bool,
/** you must provide this prop, it will be used only for validation. */
value: PropTypes.bool.isRequired,
value: PropTypes.any.isRequired,
}