Rebass: exteneding Banner component.

Created on 2 Sep 2017  路  2Comments  路  Source: rebassjs/rebass

Hello :D
First of all thanks for awesome component library 馃槃
I am trying to extend banner component, and having trouble with changing flex related props.
exteneding Banner component.
I am having this error message on my chrome browser.

 Unknown props `alignItems`, `justifyContent`, `minHeight` on <div> tag

I think this happens because of the banner component is using div...
Can anyone give me a hint to solve this problem?
Thanks

Most helpful comment

Hey @oiojin831 those aren't valid attributes on the Banner component and not part of the rebass blacklist. This is more of a styled-component problem which has been discussed here https://github.com/jxnblk/rebass/issues/266.

Here's a way to extend rebass components while mitigating the unknown props error.

import { Banner as RebassBanner } from 'rebass';

const Banner = styled(({ alignItems, justifyContent, minHeight, ...restProps }) =>
  <RebassBanner {...restProps} />,
)`
  align-items: ${props => props.alignItems};
  justfiy-content: ${props => props.justifyContent};
  min-height: ${props => props.minHeight};
  background: #00F;
`;

export default Banner;

All 2 comments

Hey @oiojin831 those aren't valid attributes on the Banner component and not part of the rebass blacklist. This is more of a styled-component problem which has been discussed here https://github.com/jxnblk/rebass/issues/266.

Here's a way to extend rebass components while mitigating the unknown props error.

import { Banner as RebassBanner } from 'rebass';

const Banner = styled(({ alignItems, justifyContent, minHeight, ...restProps }) =>
  <RebassBanner {...restProps} />,
)`
  align-items: ${props => props.alignItems};
  justfiy-content: ${props => props.justifyContent};
  min-height: ${props => props.minHeight};
  background: #00F;
`;

export default Banner;

Closing this since I think the above comment addresses the question

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jckw picture jckw  路  6Comments

karland picture karland  路  7Comments

JaKXz picture JaKXz  路  4Comments

jxnblk picture jxnblk  路  5Comments

jamesknelson picture jamesknelson  路  4Comments