0
export { width as responsiveHeight } from "react-native-responsive-dimensions";

I want to export responsiveHeight with name width. What is correct way to do this? As this is not working.

3 Answers 3

4

Your syntax is opposite. You want to get responsiveHeight as width.

Try this

export { responsiveHeight as width } from "react-native-responsive-dimensions";
Sign up to request clarification or add additional context in comments.

Comments

2

You're actually doing the opposite, you are taking your width function and add it an alias called responsiveHeight, so you need to do this:

export { responsiveHeight } from "react-native-responsive-dimensions";

just as simple as that, export width in that way, it should work with no issue.

3 Comments

Thanks can you tell me what width as responsiveHeight this syntax mean?
By the way responsiveHeight is a function of react-native-responsive-dimensions
width as responsiveHeight you are telling your code export the function/variable called width into react-native-responsive-dimensions and export it as responsiveHeight, I mean you are exporting that with an alias name, so then when you are importing that function you can import it like this: import { responsiveHeight } from '../path/to/file' and not as width because you gave an alias.
-1

Try This One.

import React from "react";
import {responsive} from "react-native-responsive-ui";

@responsive
export default class Debug extends React.Component {
    render() {
        const {width, height} = this.props.window;
        console.log(`New window dimensions: ${width}x${height}`);
        return null;
    }
}

1 Comment

How to use this ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.