Skip to content Skip to sidebar Skip to footer

Reactjs Read A Properties File?

I have trouble looking for a solution on how to read a properties file in reactJS. I've read that you can use the module 'properties-reader' but I can't seem to make the require wo

Solution 1:

Here's a simple way to import/export an object (in a .js file) so you can re-use it across multiple files:

/* properties.js */exportconst properties = {
    content: "This is a string"
};

Then in your react component:

importReact, { Component } from'react';
import { properties } from'./properties.js';

classMainextendsComponent {

    render() {
        return (
            <div>
                {properties.content}
            </div>
        );
    }
}

Post a Comment for "Reactjs Read A Properties File?"