Case 1.
const App = ({props,height}) => {
return(
<View style={[props,{height:height}]}></View>
)
}
App.defaultProps = {
props: true
height: 64
}
export default function App;
Case 2.
const App = ({props = true, height = 60}) => {
return(
<View style={[props,{height:height}]}></View>
)
}
export default function App;
Component.tsx
const Component = ({...rest}) => {
return(
<TextInput {...rest}}></TextInput>
)
}
export default function Component;
App.tsx
import Component from '../Component
const App = ({props = true, height = 60}) => {
return(
<Component autoFocus ></Component>
)
}
export default function App;
위처럼 Spread연산자를 사용하면 App에서 TextInput에 관한 props 작성시 적용된다.