score:2
it looks like an you are doing concat strings instead of number
i don't see add logic in your api request function but as per you showed you can fix it with below
let add = number(this.state.charge) + number(this.state.total);
console.log(add);
but important is you understand that the state you stored isn't number but typeof string.
so while updating state you can make sure it's number not an string so you don't need to convert it into number while doing concat.
Source: stackoverflow.com
Related Query
- How to make addition of state in react native
- How to make a shared state between two react components?
- How do you make the ListHeaderComponent of a React Native FlatList sticky?
- How to make sure a React state using useState() hook has been updated?
- How do I make components in React Native without using JSX?
- React Native - how to make a border image?
- How to make three.js run in React Native (without WebView)?
- How to make React input onChange set state only after onChange stops firing for set time?
- React Native - LayoutAnimation: how to make it just animate object inside component, not whole component/view?
- How to make a React component setState() based on a Redux state change?
- How can we make an animated strike through on react native text?
- How do I share state between react native screens?
- How to properly update a react native swiper component when state changes?
- React Hooks - How to use a make a state dependant on another state?
- How do I make my React state update immediately?
- How can i make a simple counter in React without using state
- How can I make react render the new state modifications after I have updated the state with hooks and context
- How to make an API call in React on state change?
- If I make a variable inside a react component, how do I re-access it on a state change?
- How can I make transient/one-off state changes to a React component from one of its ancestors?
- How do I make an axios request using a route parameter from React Router, then update state based on the response?
- React hooks, reducer, context & initial state object. How do I make my API-call?
- In React Native how do you change navigation options on state change?
- React Native TextInput have a Default Value How can we update/pass DefualtValue as a Text entry when state change (onchangetext)
- How do i make a toggle save its state between React Routes
- how to make a react component state change on window resize?
- How to make React app show the state immediately
- How to make react input show state value?
- How to make POST request with axios and React State Hook
- How to make a property in react class state with union type
More Query from same tag
- Use React-intl translated messages in Redux middleware
- need to pass an array with an object inside it
- Resize/scale entire canvas with all objects in fabricjs without loss of quality
- How to write a wrapper around a material UI component using React JS?
- Translate Django template to ReactJS
- Why is my line not breaking when I use "\n" in react?
- How can I use onClick
- Why do I get a TypeError: this.getToken is not a function - React JS
- threejs/typesript - viewer object gets destroyed after rendering once
- How can I select a specific part in my svg imported with ReactComponent as Logo?
- Cannot read property 'length' of undefined when trying to get # of objects
- Axios post with params
- event.target.value is giving value before change
- How to return child as a function in React after modifying the children with React.Children API?
- React - compounding components (Objects are not valid as a React child)
- @font-face not loading in react app (storybook)
- React JS - confirmation dialog with function callback
- Why am I getting a 'Assignment to property of function parameter ..' eslinterror?
- How to bundle in Webpack assets in multiple pages that don't link to every other assets?
- Making an API call after dispatch
- Problem in rendering API file using map and list in react
- How to refactor this kind of code to fix codeclimate duplication report?
- ESLint | Assignment to property of function parameter 'payload'
- How to test function that we get from action, has been called?
- React: useState not preserving updated state upon click
- error: Do not use Array index in keys
- I have 2 components and I want a 3rd component to show animation while waiting for the 2nd one to load images
- How to render only items searched from a list of <li> elements
- How to remove an element from a key value array?
- console errors while testing react component with font-awesome icon