score:0
yes. you can do like this:
let thevariable = *somethingnew*;
const datavalue = props.table.data.rowdata[thevariable];
score:2
you can do this through property bracket access:
let thevariable = somethingnew;
const datavalue = props.table.data.rowdata[thevariable]
this can also be used during object creation:
const datavalue = {
[thevariable]: {}
}
Source: stackoverflow.com
Related Query
- Getting a value inside props using variable
- Getting an error "A non-serializable value was detected in the state" when using redux toolkit - but NOT with normal redux
- Getting a RangeError: Invalid Time Value when using React datepicker
- CSS Emotion Library - Getting css props error when using css prop
- How to set value dynamically inside Form.List using setFieldsValue in Antd 4?
- Styling react-router-dom Link using styled-components getting warning when passing props
- Caching with Webpack, [hash] value inside index source code, using React.js
- Getting error when using FormattedMessage inside a module: Error: [React Intl] Could not find required `intl` object
- How to pass a value to a StaticQuery using props string?
- React How to set an element's ref value using a variable
- React: Getting the value of text inside a contentEditable div
- How to change a SASS variable value using React Js?
- Why is react state(array) empty inside callback function? Why is it not using the updated value from outer scope?
- React, can't access updated value of state variable inside function passed to setInterval() in useEffect()
- Getting Select Value Using React
- How to set default value of props if not passed to functional component in NextJS using Typescript
- Input type text's value not getting updated while using React JS
- Remove an object's key and value using a variable from function
- Edit text value in React array using props and state?
- React: Getting props from multiple arrays using .map
- Using classnames to dynamically style component with CSS based on props value
- Using Map function inside the render() -> return() but it's not getting displayed
- using a variable value on css modules class name
- Best practice in getting name props in options inside onChange event
- Getting a state of from a component and show it as a value attribute inside a div?
- Function not pointing to the updated value of state variable using hooks
- Getting the value of a checkbox inside another component when a button is clicked
- Adjacent sibling not getting CSS variable value
- Is there a way to access a value computed using props in componentDidMount?
- React default props value using null
More Query from same tag
- Getting the length of an array of objects in Reactjs
- Add Axios to React chart and take JSON data
- Why does child component do not re-render after prop change?
- Changing state with setState
- Multi-line split of very long text on canvas (adding line breaks)
- Concatenate local path + dynamic images from Map - React.Js
- React router redirect if not signed in
- React using forwardRef always update child component even using memo
- (jsx) Use padEnd in an element's text
- Concating string variable in array of strings
- Right way of using react-hook-form with typescript and material-ui for showing error message
- Cannot mock icons for react-inlinesvg Jest testing
- How to use an array element as a route element?
- REACT - Child position with respect of scale of parent
- React redux frontend not fetching data from Django API with axios
- Eventhandling in combination with the .map function
- handle when product not found in react
- Importing a component
- Extracting json from an array
- adding some styles to react-d3-cloud
- where is create-react-app webpack config and files?
- Action does not trigger a reducer in React + Redux
- How to pass a variable in form action url?
- capture all user interactions in a react application centrally
- React MUI: Matching the heights of two grid sections
- Behavior for single if condition (omitting else return false)
- REACT-ROUTER—Render output in parent component
- Server Side rendering in React boilerplate
- setTimeout() function is not detecting a state change and keeps executing the recursive function
- Trying to setup redux history so I can redirect