Search code examples
javascriptreactjsantdant-design-pro

How to import 2,3 object from another file in reactJS


I am beginner to ReactJS, Currently I am using styled-component for style some module. Actually I created 2 files in one folder. One is style.js where I am making 2,3 object and now I want to export these 3 object to my another file which name is 2nd.js but it not working for me Could you please help me How I can import style.js object to my file .

Style.js Code

  import styled from 'styled-components';

  export const SubText = styled.div`
  font-size: 20px;
  text-align: center;
  padding-bottom: 30px;
  width: 330px;
  color: #012653;
  margin: 0 auto;
  font-weight: 440;
`;
export const GeneralText = styled.div`
  color: red;
  font-size: 26px;
  font-weight: 600;
  text-align: center;
  min-width: 266px;
  padding-bottom: 30px;
  font-family: Lato, sans-serif;
  margin-top: 50px;
  color: #012653;
`;
export const ButtonWrapper = styled.div`
  text-align: center;
  margin-top: 26px;
`;

2nd.js Code

    import Style from './Style';

<GeneralText>This is dummy text </GeneralText>

Solution

  • You can do this by:-

    import {SubText, GeneralText, ButtonWrapper} from './style'