question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected props values when using proptypes + passing to default prop a value which imported from another package (e.g react-virtualized)

See original GitHub issue

Describe the bug I am using Storybook in a monorepo project. I have a table repo which includes Table.js component and Table.stories.js story. Within the Table component, I am importing defaultTableRowRenderer from react-virtualized (import {defaultTableRowRenderer} from react-virtualized).

  1. when i run storybook i get an exception: “Failed prop type: Invalid prop rowRenderer of type string”. the value (default value) which passed to rowRenderer is defaultTableRowRenderer. if i console.log({defaultTableRowRenderer}) it is printed as a function.

  2. the Table components props gets weird and undeclared values somehow. for instance: the Table.js component have a prop ‘onSelectedIdsChange’. this prop doesn’t have any default value and it doesn’t get any value from the story it self. when running storybook and printing ‘onSelectedIdsChange’, i get a function with the name “actionHandler”.

  • if i am reconfigure the babel overrides array in the main.js file to be []. Everything works just fine, except that i don’t get the auto configure args table.

Expected behavior i wish to see the table working as it works when configuring babel to babel: (options) => ({ ...options, overrides: [], }), and also get the auto configure args table.

Screenshots image

image

image

System System: OS: macOS 11.1 CPU: (8) x64 Intel® Core™ i7-6700HQ CPU @ 2.60GHz Binaries: Node: 12.19.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Browsers: Chrome: 89.0.4389.114 npmPackages: @storybook/addon-actions: ^6.1.5 => 6.2.7 @storybook/addon-essentials: ^6.1.5 => 6.2.7 @storybook/addon-links: ^6.1.5 => 6.2.7 @storybook/react: ^6.1.5 => 6.2.7

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shilmancommented, Apr 11, 2021

If you are installing Storybook with sb init, it will create a .storybook/preview.js which contains the following code:

export const parameters = {
  actions: { argTypesRegex: "^on[A-Z].*" },
  ...
}

This is what is generating the action handler passed into onSelectedIdsChange. You can delete/modify that line if you don’t want to actions for on* props

0reactions
nir-necommented, Apr 12, 2021

I didn’t pass “rowRenderer” as an arg. It should just get the default prop assign to it (defaultTableRowRenderer which imported from react-virtualized). So in this case, i should explicit pass it as a mapped arg in the story file?

any way, i removed the default prop and drilled it down like below image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >
How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >
React Basis: Default Props and Typechecking with PropTypes.
In this blog we review two React fundamental topics including defaults props and typechecking with PropTypes. Props are objects passed from ...
Read more >
Props and PropTypes | Mastering React Native
import React, { Component } from 'react'; export default class Title extends ... The PropTypes module comes with functions for validating different value...
Read more >
Default Props in React/TypeScript - DEV Community ‍ ‍
For the 3 optional props, default values are assigned. If the component is wrapping other content, that content will be rendered with props....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found