score:1
Accepted answer
you can use inline styling where this.state.score
will be your value for left
property:
style={{ left: `${this.state.score}%` }}
you can use back-ticks to concatenate % string with score
value at the end:
<div
classname={
!this.state.listening
? 'results-container'
: 'results-container-closed'
}
>
<div classname="result-wrapper">
{this.state.score === ''
? 'click record and check your score'
: 'your score: ' + this.state.score}
</div>
</div>
<div classname="scale-container">
<div classname="bar">
<div classname="arrow-up" style={{ left: `${this.state.score}%` }}></div>
<div classname="scale-meter"></div>
<span></span>
</div>
</div>
Source: stackoverflow.com
Related Query
- How can I pass a value from the backend to a React frontend and use that value in the CSS for the frontend?
- How can I cache data that I already requested and access it from the store using React and Redux Toolkit
- How to display and handle dynamic checkoxes that are dependent on Task array value in the backend (Mongodb) in react js?
- how to pass the current item to the function so that i can remove it from array in react component?
- How can I redirect to another component in react and pass the state that I set in the previous component?
- How to use the useHook in the component rather than passing the value returned from it as a prop to the components using react and typescript?
- How can i store the value of a React input element and use it in some other elements
- How can I take a value from an input tag in a TSX component, and use that value in a Node JS file in a different directory?
- How can I get the value of an input field and use it in URL in React
- pass boolean state value from parent class to child class when a button is clicked in the parent class in react js so that i can load quizes with bool
- How to pass a json array that comes from backend to child component using props and react hooks?
- How can I turn the data that is a image came from API to url to use in img tag in react Js
- How to Extract the id from a class div in react JS such that i can assign the value of div id to a variable in my code
- How can I use React Router to change routes from within a component that is also Routed in the Main App.js component?
- How can I get the value of an element onClick in React and use it as condition
- How can i set the initialState value from the backend to use in form input value? Input doesn't change after giving value = product.name from Backend
- How can I send the user saved in passport from the backend server to the React frontend server?
- Which strategy to use when displaying a value on the screen that comes from a useState hook of React and not re render unless under an action?
- How can I update react app that gets it's data from the node mongo backend using redux
- How can I pass CSS classes to React children and ensure they will override the child’s local class?
- How can mock the value of a state and data in my react test
- How to use setFieldValue and pass the value as props between components
- How do I manage state on a React component that can have state changed from the parent or from events upon it?
- how to put backend and frontend together - returning react frontend from fastapi backend endpoint
- How can I use react useContext , to show data from context, in the same component
- How do we return a Promise from a store.dispatch in Redux - saga so that we can wait for the resolve and then render in SSR?
- How to activate a react route and pass data from the service worker?
- How can I get the value from an animated or interpolated value in React Native?
- I can not get the state from react router Link component using useLocation. So how can I pass it?
- How can i use the value that is been returned by my reducer
More Query from same tag
- Two way databinding does't work with multiple check boxes dynamically loaded in React
- React.js - call useDocument hook conditionally
- Use Typescript declaration types inline
- Nested axios calls updating react state before all requests have finished
- How to apply styles to a function in React js using hooks
- JsPDF - Image cut on little screen
- How to vertically separate Material UI Gridded Paper components?
- Accessing filtered object values from props (JS/React)
- How to add Nested and Non-Nested Routes with React Router - ReactJS?
- react-router-dom v6 useNavigate passing value to another component
- How do I render different components on a page according to some action defined inside those said components?
- React best way to handle empty object before mount?
- Converting string into HTML Code in React js
- Clicking same item closes menu but different item keeps menu open
- How can I get an image from Youtube search App in react?
- Pending Status in Network when trying to Create new entry in table
- Getting length of list present in state not working
- React: How to publish page on server using React-starter-kit
- Why are backticks returning undefined in React
- Can you have a globally accessible function in a React App?
- How to configure the left-bar menu with sub menus in admin-on-rest?
- Change a value in a nested object using useState in reactJs
- Changing the default style for a Navigator.NavigationBar (title)
- Not able to align menu items horizontally in navigation bar
- Error showing while npm run build
- ReactJS Submit form with default values
- react final form add extra fields as props
- REACT JS How can I display my fetched API data from onClick?
- I would like to style the color of a button to primary if the selected button value equals to any of the `key` of an object
- How to target backdrop color property of Material UI Dialog using styled components?