Defined component style not working

letthefireflieslive

margin-top style is not being applied to the component. I don't quite understand what I'm missing here.

Home.js

const BannerSd = styled(Banner)`
    margin-top: 15%;
`;

class Home extends Component {
  render() {
    return(
      <div>
        <BannerSd/>
        <Content/>
      </div>
    );
  }
}

export default Home;

Banner.js

function Banner() {
    return (
        <div>
            <h1>Title</h1>
            <h3>SubTitle</h3>
        </div>
    );
}

export default Banner;
T Porter

You need to pass the className down to the Banner component, as described in the styled-components docs.

function Banner({className}) {
    return (
        <div className={className}>
            <h1>Title</h1>
            <h3>SubTitle</h3>
        </div>
    );
}

export default Banner;

Edit: Wrong link

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

working with joomla 2.5 users component

来自分类Dev

Symfony\Component\DependencyInjection\Exception\InvalidArgumentException The parameter "..." must be defined

来自分类Dev

Cannot set React Native Animated value to View component CSS style

来自分类Dev

使用 *.component.scss 而不是只在 style.scss 中编写它有什么好处?

来自分类Dev

is_defined constexpr函数

来自分类Dev

tree with defined Type in haskell

来自分类Dev

ReferenceError: module is not defined in jasmine

来自分类Dev

ReferenceError: $ is not defined jquery 错误

来自分类Dev

PHP defined() 的奇怪行为

来自分类Dev

UITableViewRowAction custom style?

来自分类Dev

Select element with certain style?

来自分类Dev

Change ftp css style

来自分类Dev

Setting global style in XAML

来自分类Dev

<style>标签内的Angularjs

来自分类Dev

Style the First Occurence of a Class

来自分类Dev

How to format text with style

来自分类Dev

与grb的style.background

来自分类Dev

对于<span style =

来自分类Dev

How to achieve this style of UITextField

来自分类Dev

覆盖 HTML Style="" 元素

来自分类Dev

Vue.js import child component into a component

来自分类Dev

Karma error - Expected undefined to be defined

来自分类Dev

Rescue from an error that may not be defined

来自分类Dev

User defined data schemas for applications

来自分类Dev

Nodejs 'res is not defined' inside require

来自分类Dev

如何修复“ReferenceError: hello is not defined”

来自分类Dev

Why is computed style in mobile safari differing from ruled style?

来自分类Dev

Style对象不能影响其应用的对象的Style属性

来自分类Dev

Show Font-Style in a Combobox in it's own style