react-select in flex container

浪子不回头ぞ 提交于 2019-12-02 08:49:22

问题


How can I make react-select to respect flex layout? Nothing of the below worked.

 const Container = styled('div')`
   width: 100%;
   height: 100%;
   display: flex;
   flex-flow: row wrap;
   justify-content: space-around;
   align-items: baseline;
 `;

const selectStyles = {
  input: base => ({
    minWidth: 200,
    flex: 1,

<Container>
<Select
  style={{ flex: 1 }}
  styles={selectStyles}

回答1:


To make your react-select component flex you need to apply flex:1 props on the container like this:

const styles = {
  container: base => ({
    ...base,
    flex: 1
  })
};

<Select styles={styles} />


来源:https://stackoverflow.com/questions/54234709/react-select-in-flex-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!