1

Suppose I have a custom CoolButton object that accepts props like width={20} height={50} and backgroundColor={"#fff"}. Is there a way I could put all the props in a different file and then invoke these props with a single name?

So for example:

props.js

allProps = {
    width={20}, 
    height={50}, 
    backgroundColor={"#fff"}
}

app.js

<CoolButton allProps><Text>Button Text</Text></CoolButton>
zengod
  • 1,114
  • 13
  • 26
  • `Button Text` You can firstly export props and import props in app and then spread it like this. – Jai Jan 14 '20 at 11:53
  • Create a valid object literal: `allProps = { width: 20, height: 50, backgroundColor: "#fff" }` and spread it: `` – adiga Jan 14 '20 at 11:55
  • Doing that gives me: "import must be from a react component". – zengod Jan 14 '20 at 12:26

0 Answers0