react-proptypes Questions

3

i have component with a simple structure and a <Text> somewhere inside the tree for which i want to pass in a style. Which works perfectly but for the proptypes validation. The basic setup i...
Crowfoot asked 1/2, 2018 at 15:0

2

Solved

What's the difference between PropTypes.exact({ name: PropTypes.string, age: PropTypes.number }) vs PropTypes.shape({ name: PropTypes.string, age: PropTypes.number }) I will be glad of an...
Weller asked 24/11, 2019 at 15:29

4

Solved

I am trying to use forwardRef for a Button in a project using eslint and prop-types. This is what I tried so far, and the errors I get each time: First attempt function Button ({ action = { call...

3

I ran npm install prop-types --save-dev and started getting this error 'prop-types' should be listed in the project's dependencies, not devDependencies import/no-extraneous-dependencies Later I uni...
Ichthyosis asked 24/1, 2021 at 0:39

8

Solved

I'm writing Jest tests for my React code and hoping to make use of/test the PropType checks. I am quite new to the Javascript universe. I'm using npm to install react-0.11.2 and have a simple: var...
Joan asked 30/9, 2014 at 15:45

4

Solved

I have a React component which I would like to enforce one of two props to be provided - if neither is provided I'd like to be able to trigger a PropType warning: MyComponent.propTypes = { firstP...
Interrex asked 22/10, 2018 at 18:20

5

Solved

Is there a better way to validate if a number is inside a range? Avoiding to write PropTypes.oneOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Agiotage asked 23/5, 2018 at 13:15

2

Solved

I am trying to create my own private component library. I manage to show the description of the prop using prop-types but the expected values are not shown. I haven't seen any documentation regardi...

2

components: DropdownItem reactstrap version ^8.0.0 react version ^16.8.6 bootstrap version ^4.3.1 I am using reactstrap dropdown. And I am trying to populate the dropdown items using a map funct...
Danieu asked 22/5, 2019 at 20:29

6

Solved

Does using React.PropTypes make sense in a TypeScript React Application or is this just a case of "belt and suspenders"? Since the component class is declared with a Props type parameter: interfa...
Selfdevotion asked 19/1, 2017 at 15:45

9

Solved

Given a simple component that renders its children: class ContainerComponent extends Component { static propTypes = { children: PropTypes.object.isRequired, } render() { return ( <div&gt...
Guerdon asked 8/2, 2017 at 20:0

2

I'm using the prop-types library in my React application and have the following situation: MyComponent.propTypes = { foo: PropTypes.arrayOf( PropTypes.shape({ bar: PropTypes.string.isRequired, ...
Icebox asked 28/5, 2018 at 16:8

2

Not sure if this is the right community for it but it's worth a shot for me: I'm using PropTypes from the prop-types npm package. It's perfect for typing your React app but one thing that's really ...
Subheading asked 17/11, 2021 at 13:24

6

Solved

I have the following PropTypes: SmartTable.propTypes = { name: React.PropTypes.string.isRequired, cols: React.PropTypes.array.isRequired, rows: React.PropTypes.array.isRequired, }; but the lint...
Bara asked 20/1, 2017 at 19:44

4

Solved

How do I mark a property as having to be a DOM element? This page says that PropTypes.element is actually a React element, so what's the equivalent for DOM element?
Apivorous asked 8/9, 2016 at 23:37

4

By default prop-types do not run in production for a react app. I realize this is a good thing to improve performance. However, we have a Storybook that we have built and are deploying it to a stat...
Astronaut asked 29/4, 2020 at 15:33

2

Solved

Is it possible to define a type for an object's with a required key value pair and a default key value pair? Example: const myComponent = (props) => { const { myObject: { someRequiredString...
Consummation asked 13/8, 2019 at 11:32

3

I have created two models State and City in separate files. Importing City in the State. State can have an array of Cities inside it. The below code works fine. State.js let State = PropTypes....
Falbala asked 20/1, 2017 at 10:17

1

We have a component like: import PropTypes from 'prop-types'; import React from 'react'; export default class Tooltip extends React.Component { static propTypes = { /** * Some children componen...
Stria asked 25/11, 2020 at 20:37

2

Solved

I'm writing a project based on react native. I'm using prop-types for type checking of components. now I wanna wrap Image component of react-native in my own Image component. In the following code ...
Imprescriptible asked 9/10, 2018 at 11:59

7

Solved

I'm setting up a new React with the help of: Create React App However, I'm running into a linting issue. I'm receiving the following linting error 'PropTypes' is not defined. (no-undef). Here is th...
Dubose asked 15/8, 2017 at 12:7

2

Solved

In React class components with mapStateToProps, mapDispatchToProps every incoming state/dispatch prop is easy to type check with PropTypes. When rewriting mapStateToProps -> useSelector, and ma...
Summons asked 25/9, 2019 at 20:55

2

I want to allow a component to having one of two possible proptypes (string or undefined). I am using PropTypes.oneOfType to do this. import React from 'react'; import PropTypes from 'prop-types'; ...
Earthwork asked 19/8, 2020 at 15:55

4

Solved

This is the use case: A component TableGroup should require a user to specify data property which is an array of objects to be rendered in the table or requestDataUrl property from where the compon...
Subjacent asked 6/5, 2017 at 6:12

3

I'm refactoring a React application from Javascript to Typescript but I'm having some troubles migrating especially the shape PropType. My code looks like this right now: import React from 'react'...
Gonnella asked 11/12, 2019 at 16:6

© 2022 - 2024 — McMap. All rights reserved.