PeculiarVentures / peculiar-react-components

https://peculiarventures.github.io/peculiar-react-components/
MIT License
2 stars 3 forks source link

Typings issues #122

Closed dmytro587 closed 1 year ago

dmytro587 commented 1 year ago

I'm got a several warnings during passing unit tests on the Hancock.

  1. Tooltip. Need to mark children prop as optional since we get warning if pass null or undefined. It get rid of us from the Failed prop type: The prop 'content' is marked as required in 'Tooltip', but its value is 'null' warnings.

  2. TooltipPopper. Need to mark children prop as optional, it get rid of us from the Failed prop type: The prop 'children' is marked as required in 'TooltipPopper', but its value is 'null' warnings.

  3. Typography. Need to mark children prop as optional, it get rid of us from the Failed prop type: The prop 'children' is marked as required in 'Typography', but its value is 'undefined' warnings.

  4. Tooltip & TooltipPopper. I got Failed prop type: Invalid prop 'usePortal' supplied to 'Tooltip' and Failed prop type: Invalid prop 'usePortal' supplied to 'TooltipPopper' warnings, but to the prop was passed a correct value. I have a guess about the wrong type definition of usePrortal here and here, the usePortal: PropTypes.oneOfType([PropTypes.bool, HTMLElementType]) definition according to the documentation fixed warnings for me.

donskov commented 1 year ago

Should be fixed in lib-react-components@3.1.5. Please try.

dmytro587 commented 1 year ago

Should be fixed in lib-react-components@3.1.5. Please try.

You probably accidentally close this issue instead of #123 because in new version fixed only bug described on #123

donskov commented 1 year ago

Yes. My mistake. Reopened.

donskov commented 1 year ago

@dmytro587 Could you provide an example of using? I do not understand a little, for example, why should we render the Typography without content.

dmytro587 commented 1 year ago

@dmytro587 Could you provide an example of using? I do not understand a little, for example, why should we render the Typography without content.

  1. Typography. I don't see the point about require children prop since: 1.1. null and undefined is valid values for the render 1.2. we don't handle rendering if children is falsy value, we still render children whatever it is, so at the moment we get a warning on an empty space. I've done a little research on some other libraries and they don't give warnings if pass falsy values to them, and just display nothing. For example https://codesandbox.io/s/pjll5x?file=/demo.tsx Ant Design has Typography with margins too.
  2. Tooltip and TooltipPopper. We have some places on the Hancock where content prop could be falsy, and again, pushing back from other ui components libs - when content for tooltips is empty he just not displayed.
donskov commented 1 year ago
  1. I will make the changes, but I still don't understand why we need empty text. We don't use any margin there.
donskov commented 1 year ago
Successfully published:
 - lib-react-components@3.1.6