0

Please can someone tell me how to format the marginLeft value? I can't figure out how to escape the dash when declaring properties in this way. I have tried quite a few different ways but none have worked. Please also let me know if it is not possible at all. Thanks.

import React from "react";

const informationStyle = { 
  fontSize: "0.6rem",
  marginLeft: "get-spacing(small)"
};

const Information = () => (
   <span style={informationStyle}>
      <svg className="cp-icon-svg cp-icon-circle" /></svg>
   </span>
);

export default Information;
4
  • what is get-spacing(small) in mraginLeft Commented Mar 20, 2018 at 14:45
  • it comes from a sass spacing map Commented Mar 20, 2018 at 14:47
  • You need to make a class in sass and use className ratherThan use style Commented Mar 20, 2018 at 14:48
  • here a template to use sass with react github.com/bsmahala/react-redux-route-sass-login Commented Mar 20, 2018 at 14:51

1 Answer 1

1

You're trying to use Sass in the React component? I don't believe that's possible. What you could do is simply put the Sass inside a separate Sass file, compile that into css, and then import the css into your project.

import './yourCssFile.css'; // Put this below your React import

const Information = () => (
   <span className="informationStyle"> // informationStyle is inside yourCssFile
      <svg className="cp-icon-svg cp-icon-circle" /></svg>
   </span>
);

You could also use Css modules rather than importing the full Css file. You can learn more about Css modules here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.