How to access props inside jsx file

Hi I am using Atlassian Connect Express. I want to pass data from index.js to hello-world.jsx.

This is my index.js file:

export default function routes(app, addon) {
    // Redirect root path to /atlassian-connect.json,
    // which will be served by atlassian-connect-express.

    app.get('/', (req, res) => {
        res.redirect('/atlassian-connect.json');
    });

    // This is an example route used by "generalPages" module (see atlassian-connect.json).
    // Verify that the incoming request is authenticated with Atlassian Connect.

    app.get('/hello-world', addon.authenticate(), (req, res) => {
	
        var hideAdminPanel = true; // I want to pass this data
		
        // Rendering a template is easy; the render method takes two params: the name of the component or template file, and its props.
        // Handlebars and jsx are both supported, but please note that jsx changes require `npm run watch-jsx` in order to be picked up by the server.
		
        res.render(
          'hello-world.jsx', // change this to 'hello-world.jsx' to use the Atlaskit & React version
          {
            title: 'Atlassian Connect'
            , hideAdminPanel: hideAdminPanel // How do I access it inside hello-world.jsx file now
            //, issueId: req.query['issueId']
            //, browserOnly: true // you can set this to disable server-side rendering for react views
          }
        );
    });
}

This is my hello-world.jsx file:

import React, { Fragment } from "react"
import ButtonGroup from "@atlaskit/button/button-group"
import LoadingButton from "@atlaskit/button/loading-button"
import Button from "@atlaskit/button/standard-button"
import TextField from "@atlaskit/textfield"

import Form, {
  ErrorMessage,
  Field,
  FormFooter,
  HelperMessage,
  ValidMessage
} from "@atlaskit/form"

export default () => (
  <div
    style={{
      display: "flex",
      width: "400px",
      maxWidth: "100%",
      margin: "0 auto",
      flexDirection: "column"
    }}
  >

    <Form
      onSubmit={data => {
        console.log("form data", data)
        return new Promise(resolve => setTimeout(resolve, 2000)).then(() =>
          data.username === "error" ? { username: "IN_USE" } : undefined
        )
      }}
    >

      {({ formProps, submitting }) => (
        <form {...formProps}>
          <Field
            name="username"
            label="User name"
            isRequired
            defaultValue="hello"
          >

            {({ fieldProps, error }) => (
              <Fragment>
                <TextField autoComplete="off" {...fieldProps} />
                {!error && (
                  <HelperMessage>
                    You can use letters, numbers & periods.
                  </HelperMessage>
                )}

                {error && (
                  <ErrorMessage>
                    This user name is already in use, try another one.
                  </ErrorMessage>
                )}

              </Fragment>

            )}

          </Field>

          {/* Dynamic Field */}
		  
          {/* I want to access that field below here, but I am unable to find a way to do so*/}
          {hideAdminPanel ? null : (
            <Field name="adminpanel" label="Admin panel field" isRequired defaultValue="">
              {({ fieldProps, error }) => (
			  
                <Fragment>
                  <TextField autoComplete="off" {...fieldProps} />
                  {!error && (
                    <HelperMessage>
                      You can use letters, numbers & periods.
                    </HelperMessage>
                  )}

                  {error && (
                    <ErrorMessage>
                      This user name is already in use, try another one.
                    </ErrorMessage>
                  )}
                </Fragment>

              )}
            </Field>
          )}
		  
          {/* Dynamic Field */}

          <FormFooter>
            <ButtonGroup>
              <Button appearance="subtle">Cancel</Button>
              <LoadingButton
                type="submit"
                appearance="primary"
                isLoading={submitting}
              >
                Sign up
              </LoadingButton>
            </ButtonGroup>
          </FormFooter>
        </form>
      )}
    </Form>
  </div>
)

How do I pass the property hideAdminPanel from index.js and access it inside hello-world.jsx ?

Hi @SyedRafay ,

Your express backend needs to serve the HTML resource that will contain your ReactJS front end. Perhaps the best way forward is to look at a few guides to explain it such as How to Set up a Node.js Express Server for React | Engineering Education (EngEd) Program | Section and How to create a React frontend and a Node/Express backend and connect them.

Regards,
Dugald

Hey @dmorrow I have already setup the application backend and frontend using Atlassian Connect Express.

Now I just want to pass data from index.js to hello-world.jsx.

Well I found out we can access the data passed from index.js to any jsx file (hello-world.jsx in this case) by changing export default () => in jsx files to export default (props) => and then access the data as props.yourdata (props.hideAdminPanel in this case).