score:1
Accepted answer
it receives the props just fine.
the problem is with your switch
statement. your case
expressions result in true
or false
so that is what should be in the switch
switch (true) {
case this.props.percentage > 75:
type = "succes";
break;
case this.props.percentage > 50 && 75 >= this.props.percentage:
type = "mediocre";
break;
case this.props.percentage <= 50:
type = "failure123";
break;
}
(also added =
to the second and third cases so that there are no unhandled cases)
Source: stackoverflow.com
Related Query
- Perform calculation in higher order component in reactJS
- Reactjs - Higher Order Component unmount not working correctly
- How to add a button using Higher Order Component in reactjs
- Higher Order Component not firing wrapper render in ReactJS
- Reactjs - Higher Order Component / findDOMNode not working correctly
- Pass props through a higher order component from a Route
- React Higher Order Component forces re-render of wrapped component
- Using hooks in a higher order component
- Higher Order React Component for Click Tracking
- Mocking a higher order component with jest
- Enzyme testing an authentication Higher Order Component (HOC)
- Access prop outside of class in React when calling Higher Order Component
- Type annotation for React Higher Order Component using TypeScript
- Higher Order Component redux dispatch being overwritten by wrapped component redux dispatch
- How to type a higher order component with flow
- Get DOM node of wrapped component in a higher order component (HOC)?
- "this" in react higher order component
- React Higher Order Component - call function in the wrapped component from the wrapper component
- How to use this higher order component explained in the Redux Doc?
- React Higher order component Vs Parent component
- passing a type argument for the props of a react component for a higher order component
- Typescript Higher Order Component as Decorator
- Using a higher order component to add event listeners per component
- Why componentDidMount in higher order component called more than once?
- React Function Higher Order Component
- Style problems with higher order component & Material-UI's makeStyles
- React Typescript: exclude property in higher order component
- Higher order component always rerenders ignoring shouldComponentUpdate
- Why typescript does not ensure type safety in a generic higher order component that adds additional properties in React?
- Flow Type higher order component (HOC) props type preservation
More Query from same tag
- How to use React Portal?
- Running into problems using React Datepicker with rails
- How can i persist with the state of a particular checkbox in filter button
- How can a parent alter props for a child component in react?
- useContext returns undefined although it seems like everything is right
- React only sometimes is throwing cannot map property 'map' of undefined
- Why my Webpack does not loading background image?
- React.lazy import { StudentDashaboard, StudentLearningView } from './studentView.jsx';
- How can i display the quantity of the items in my shopping cart on every pages of my react/nextjs application
- React/Redux not updating the state
- isAuthenticated is always null
- Failed to compile
- Mocking library hook with Jest
- Keeping state of input breaks app when value is undefined
- How can I get separated states from multiple child components in React.js?
- Unpredictable behavior of y-axis labels of Highchart
- Can I delete props in react
- Not able to add, update, delete rows in material table react using class based component. Previously it was working with functional component
- Exclude .js files from build React.js
- Monitor Firebase Auth Object property changes?
- React countdown using Material UI ProgressBar
- Getting the data inside my array
- TS2739 Type 'any[]' is missing the following properties from type 'JSON': parse, stringify, [Symbol.toStringTag]
- Why doesn't comparing arrays in componentDidUpdate lead to infinite loop?
- React Leaflet: Dynamic Markers, cannot read property 'addLayer'
- React Redux missing in props validation and recommended pattern for initialising container from an external API using redux-observable
- TypeError: Cannot read property 'clientWidth' of undefined
- How to make the row editable when clicking on an "Edit" button on a cell with react-table
- Custom mailchimp signup form in React
- How to get FCM token?