0

Tryping to implement type for position object where it stores dynamic keys and returns objects which I will destructure in React Component as props:


interface Position  {
 [key: NotificationPositions]: any
}

const positions:Record<NotificationPositions,any> = {
  'top': {
    top: "0",
    right: "0",
    left: "0",
    alignItems: "center",
  },
  "top-right": {
    top: "0",
    right: "0",
    alignItems: "flex-end",
  },
  "top-left": {
    top: "0",
    left: "0",
    alignItems: "flex-start",
  },
  'bottom': {
    bottom: "0",
    right: "0",
    left: "0",
    alignItems: "center",
  },
  "bottom-left": {
    bottom: "0",
    left: "0",
    alignItems: "flex-start",
  },
  "bottom-right": {
    bottom: "0",
    right: "0",
    alignItems: "flex-end",
  },
};

well I couldn't do it and I couldn't find information on the internet so I am asking here. Maybe answer is available on internet but I don't know how to search it. So any help is appriciated. Thanks.

1
  • What's the problem with your approach ? Commented Sep 11, 2022 at 19:01

1 Answer 1

1

Your data looks like react style attribute, so it looks like you need something like this

interface Position  {
 [key: NotificationPositions]: React.CSSProperties
}
Sign up to request clarification or add additional context in comments.

1 Comment

It's Chakra UI attributes

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.