score:3
Accepted answer
this warning is coming because left
or top
being nan
. initialize your left or top to zero or some value in getinitialstate function
.
getinitialstate: function() {
return {
left:0,
top: 0
};
also cloning react-element won't help you here. warning is saying you have to clone your style object when you are making changes to it. which can be done as
var style1 = {myprop: "value"};
var style2 = object.assign({}, style1, {newprop:"newvalue"});
instead of setting them directly as
<componentone style={{left: this.state.left, top: this.state.top}} />
do in this way
var mystyle = {left: this.state.left, top: this.state.top};
<componentone style={mystyle} />
and then based on your changes clone your mystyle object and add changed style properties to it.
Source: stackoverflow.com
Related Query
- React how to update style coordinates
- How to update style element in Ant Design React component using Javascript
- How to update nested state properties in React
- How to update React Context from inside a child component?
- How do I update states `onChange` in an array of object in React Hooks
- How to define css variables in style attribute in React and typescript
- How to test style for a React component attribute with Enzyme
- How to test a prop update on React component
- How to update array state in react native?
- How to update react state without re-rendering component?
- How to update webpack config for a react project created using create-react-app?
- React hooks: How do I update state on a nested object with useState()?
- How to draw dashed border style in react native
- How to add style to React Element if it's created this way?
- How to style React Native <CheckBox> component?
- How to unit test a style of a React Component using Jest.js?
- How to style child components in React with CSS Modules
- How to update object in React state
- ReactJS - How to change style and class of react component?
- React how to update another component's state?
- how to update multiple state at once using react hook react.js
- How to update the state of a sibling component from another sibling or imported component in REACT
- How do you update Formik initial values with the react context api values after an AJAX request?
- How to add style - like margin - to react component?
- React Navigation: How to update navigation title for parent, when value comes from redux and gets updated in child?
- How to set -webkit-overflow-scrolling inline style on react component
- How to update the router state on history.replace in react router?
- How to add multiple style attributes to a react element?
- How to style nested elements in react with styled-components?
- How can I test React component's style with Jest + Enzyme?
More Query from same tag
- useReducer to retain object state and update a specific item
- Load an image with only some character begin of the filename in react
- How to load new component on button click
- Firebase `displayName` returns Null - React JS
- firebase SSR problem, "App requesting permission to access your google account" pops up instead of website
- React: Conditional Rendering Of Components And Arrays
- Flex Box Items not aligning with the above row
- Is there any way to run asscroll package in react project?
- css animate div from bottom to middle
- Hide comma if the following word isn't present in React
- Typescript React.Js File Upload Event Ts2322 Error
- Dependant Select Components not showing the Selected Value in Input Field
- Ant design responsive NavBar
- React. Why this.state does not updates correctly?
- React Router pathes
- AWS Amplify federatedSignIn Error: Cannot read property '_config' of undefined
- Use state in React causing value of const to break
- How to store a component and render conditionally
- React Dev Tools: "parse hook names" action throws a "Hook parsing failed" error
- How to set up routes and redirect in React
- How to iterate an array of objects through each object element?
- AWS Amplify HOC Authenticator React does not pass authState property to wrapped component
- Render a component when another component is clicked
- React detect click outside a component with custom hook
- How to update an array using redux reducer, I want to change a boolean property inside an array of objects to make i true or false
- How do I model an array to be sent as JSON in Express/NodeJS to ReactJS?
- How to optimize big array comparision
- REACT ES6 Update state from parents updated props
- Mapbox-GL-JS + REACT: linking radio button to switch the layers of the map
- SVG files are emitted, but appear to be corrupted in a single-spa react module. How to load SVG files in single-spa projects?