0

Why inline styling doesnt work in react on components?I dont understand why this is not working.I know is possible to make it different ways.(with css files for example).Im just corius.The intellisense does not help by inline styling either.Its strange..

import "./App.css";
import Button from "./components/Button";

function App() {
  return (
    <div className="App"  >
      <Button style={{fontSize:"50px"}} />
    </div>
  );
}

export default App;

//this is from Button components

import React from "react";

const Button = () => {

  return (
    <div>
      <button>
        Change
      </button>
    </div>
  );
};

export default Button;

1 Answer 1

3

You need to pass the style property to the Button component:

const Button = ({style}) => {

  return (
    <div>
      <button style={style}>
        Change
      </button>
    </div>
  );
};
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.