0

enter image description here

I want to add props to control my css in emotion,but I don't know how to do

1 Answer 1

1

You can wrap it inside a function and handle your function param as prop.

const getMessageWrapperStyle = (props) => {
  css({
    display: "flex",
    alignItems: "center",
    marginBottom: "20px",
    alignSelf: props.from_user === currentId ? "flex-end" : "flex-start",
  });
};

And then use it like that:

css={getMessageWrapperStyle({ from_user: message.from_user })};
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.