React inline style - style prop expects a mapping from style properties to values, not a string
Use "styles" prop instead of style
<span className="myClass" style={{float : 'left', paddingRight : '5px'}} > </span>
Here is a great reference from W3Schools which also shows you how to create an object with styling information, and refer to it in the style attribute:
reference for how to style React using CSS
Error: The `style` prop expects a mapping from style properties to values, not a string in ReactJS
Change the style
prop to an object and camelCased properties:
<h1 style={{fontSize: `50px`}}>I am John Doe</h1>
See style
in React docs.
The
style
attribute accepts a JavaScript object with camelCased properties rather than a CSS string.
The `style` prop expects a mapping from style properties to values, not a string
Try removing "" from the style props. https://codesandbox.io/s/6j91o6z56w
import React, { Component } from 'react';
class App extends Component {
render() {
const name = 'Red Header';
const styleRed = {backgroundColor : 'red'};
return (
<div style={styleRed}>
{name}
</div>
);
}
}
Error: The `style` prop expects a mapping from style properties to values, not a string
You need to add the fill property in the svg element as shown below,
import React from "react";
const TwitterIcon = () => {
const { fill, width, height } = styles;
return (
<svg
viewBox="328 355 335 276"
height={height}
width={width}
xmlns="http://www.w3.org/2000/svg"
fill={fill}
>
<path d="M 630, 425A 195, 195 0 0 1 331, 600A 142, 142 0 0 0 428, 570A 70, 70 0 0 1 370, 523 A 70, 70 0 0 0 401, 521A 70, 70 0 0 1 344, 455 A 70, 70 0 0 0 372, 460A 70, 70 0 0 1 354, 370A 195, 195 0 0 0 495, 442A 67, 67 0 0 1 611, 380 A 117, 117 0 0 0 654, 363A 65, 65 0 0 1 623, 401A 117, 117 0 0 0 662, 390A 65, 65 0 0 1 630, 425Z" />
</svg>
);
};
const styles = {
fill: "grey",
width: 210,
height: 500
};
export default TwitterIcon;
Working codesandbox
Uncaught Error: The `style` prop expects a mapping from style properties
<button onClick={this.onSignIn} style="">Sign In</button>
remove the style attribute or replace it by an object.
https://reactjs.org/docs/dom-elements.html#style
The `style` prop expects a mapping from style properties to values, not a string. Style with multiple property
You have to write it like that :
{ background: "all your properties", height: "100vh" }
please have a look at React documentation: https://reactjs.org/docs/dom-elements.html#style
Related Topics
JavaScript Beforeunload Detect Refresh Versus Close
How to Call a Js Function Using Onclick Event
Browsers Automatically Evaluate Hex or Hsl Colors to Rgb When Setting via Element.Style.Background
How to Combine Jquery Animate with CSS3 Properties Without Using CSS Transitions
How to Change Reactjs Styles Dynamically
How to View Events Fired on an Element in Chrome Devtools
Best Way to Get All Selected Checkboxes Values in Jquery
Get Keys of a Typescript Interface as Array of Strings
JavaScript Regexp + Word Boundaries + Unicode Characters
How to Listen/Detect Changes to an Input Value - When the Input Value Is Changed via JavaScript
How to Resize HTML Canvas Element
Mui Createtheme Is Not Properly Passing Theme to Mui Components
The Purpose of Starting an Initial Comment with /*! in JavaScript and CSS Files
How to Detect CSS Flex Wrap Event
Vue 2 - Mutating Props Vue-Warn
Document.Getelementbyid VS Jquery $()
Sending Message from a Background Script to a Content Script, Then to a Injected Script