score:0
Based on what I can understand you want to change the CSS class based on the scrollFirstDigit
and scrollSecondDigit
variables you've created (adding a scroll
class to the list of classes). In React I often use the classnames
modules to do things like this. For example the following maybe something you're interested in:
var classnames = require('classnames');
...
<div className={classnames({ 'number current': true, 'scroll': this.state.scrollFirstDigit === true})}>;
So you can simply toggle the CSS classes you want by altering the state object (since it will trigger a re-render and cause the revaluation of the classes). You can see more examples at the modules github page.
Source: stackoverflow.com
Related Query
- Toggling a CSS class when a React.js component gets updated
- React component not re-rendering when "Date" in state gets updated
- Add CSS class to React DOM element when updated in fetch
- Referencing css class in React component when it has -
- React Navigation: How to update navigation title for parent, when value comes from redux and gets updated in child?
- Access prop outside of class in React when calling Higher Order Component
- How to split a component when it gets big. ReactJs or React Native
- React component function returning JSX causes error when used in render method of ES6 class React component
- Custom React Component Library not loading CSS when installed as dependency in another react project
- CSS gets lost when refresh or back button pressed in react app
- Unexpected token "<" expected "{" when passing Interfaces to React Class Component
- Make a React component rerender when data class property change
- In react class component why is the state not being changed in the first instance of button click? But in the second instance it gets updated?
- React Component not updated when state changes
- Remove class name sibling component when click the current component and make toggling in current to remove class it self
- Css animated spinner is buggy in IE on Windows 8.1 when used in a React JS component
- CSS not changing when using React Router to route to another component
- How to re-rendering react class component when state is changed
- React CSS class gets override automatically on production server
- Get updated state of component when calling method on class via enzyme
- How do I create a class decorator for mixing new methods into a React component when using Typescript?
- Target a css class in 'a component generated by library' in react
- React - Using ternary to apply CSS class in functional component
- how to change the react component css class value
- React component stops working when I add css to it
- `setInterval` gets paused in React Component effect hook when window prompter is shown
- React test passes but component does not work properly when state updated in document.addListener handler
- Add class to siblings when Component clicked in React
- How can I convert class component into functional component when adding React library to a Website?
- Add new css class with out replace the olders on a React Component
More Query from same tag
- Flow : destructuring. Missing annotation in React/Preact
- populate hooks with axios json response reactjs
- typescript: How to define type as any part of enum?
- How to connect react-hook-form, react-select, and yup in typescript?
- Many resquest on GetStaticProps freezes my application build and return an server error
- Axios get in url works but with second parameter as object it doesn't
- Why useEffect hook runs before the DOM is loaded?
- How to prevent empty item in list from being displayed?
- Serving react-routes with Express
- Unable to traverse improperly grouped data from Wikipedia API
- "Res.redirect" Not Working when making Ajax call from React to Node?
- Triggering specific function on state change
- How to dispatch multiple actions
- Axios custom instance not working properly with next JS
- React.js validate props input
- Axios api call returns not found error in reactjs
- how to change the text value back to default when pressed again
- React Bootstrap fails to render
- How to include textarea field when defining model of a contact us form in react web application
- Cannot read property '_id' of undefined unhandled Rejection
- CSS Grid how to select row to add hover effect?
- React: Not getting the correct data in the inner map on click event
- How to access component methods from “outside” in ReactJS?
- How to switch MaterialUI icon when clicked
- React onChange doesn't return updated value after updating the state
- Global SASS variables in reactjs app
- How we can close the error messagebar of office react fabric component?
- React - History.replace in try/catch create an error
- Onchange is not working when editing cell of material-table in react.js
- Changing edited textbox value to the original passed value on clicking outside the div of textbox in reactJS