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.

prop type checking fails when using mobx

See original GitHub issue

When using mobx for state management the proptype checking fails:

Warning: Failed prop type: Invalid prop `data` of type `object` supplied to `BootstrapTable`, expected `array`.

The reason is that the provided property is not a simple array anymore but an ObservableArray:

@observable
  data = [...];

Any ideas how to solve this without loosing observability of the property?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mathiaswillburgercommented, May 31, 2018

Works like a charm. Solved it by slicing the array before using it:

@computed
  get dataSource() {
    return this.data.slice();
  }
0reactions
AllenFangcommented, Jun 2, 2018

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to check propTypes for observer(Component)
If you want to check if the Comp prop is a type that can be rendered, you can use PropTypes.elementType starting with prop-types...
Read more >
Runtime Type Checking - mobx-keystone
This allows you to associate arbitrary metadata with the type of a prop that you can then use at runtime against instances. const...
Read more >
How to use the mobx-react.PropTypes ... - Snyk
To help you get started, we've selected a few mobx-react.PropTypes.arrayOrObservableArray examples, based on popular ways it is used in public projects.
Read more >
mobx-react - npm
The above propTypes are incorrect, bold needs to be provided by the caller of the UserName component and is checked by React. However,...
Read more >
mobxjs/mobx - Gitter
Hello, Im trying my first steps with mobx & typescript. I checking around ... Property 'store' is missing in type '{ message: string;...
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