Forum

How to use dynamic routing in builder.ai

0
Topic starter

I want to use dynamic routing in builder.ai using RunEngine, How can I fix that?

2 Answers
1
Topic starter

To implement dynamic routing (e.g., Profile/:id), you can follow this method:

 

1. Use the predefined NavigationScreenNameMessage to pass the value in the URL. : 

    handleRecruiterNavigation = (recruiterId: number) => {
        const message: Message = new Message(getName(MessageEnum.NavigationMessage));
        message.addData(getName(MessageEnum.NavigationTargetMessage), 'Profile');
        message.addData(getName(MessageEnum.NavigationPropsMessage), this.props);
        message.addData(getName(MessageEnum.NavigationScreenNameMessage), recruiterId);
        this.send(message);
    }

 

2. Ensure that you update the path in the app.js file to handle the dynamic route.

  RecruiterProfile1:{
   component:RecruiterProfile1,
   path:"/Profile/:navigationBarTitleText",
   private: true,
   roles: ["recruiter", "candidate"]
  },

 

3. In the RecruiterProfile1.controller.tsx file, you can retrieve the value from the URL.

const recruiterId = this.props.navigation.getParam("navigationBarTitleText")

 

This post was modified 7 months ago 2 times by hardiksaraf
hardiksaraf Topic starter 18/06/2024 9:53 am
This post was modified 7 months ago by hardiksaraf

1 correction is here, key should match the pathname

Profile:{ 
  component:RecruiterProfile1, 
  path:"/Profile/:navigationBarTitleText", 
  private: true, 
  roles: ["recruiter", "candidate"] 
},
JayVadgama 30/09/2024 5:10 am

@hardiksaraf

path:”/Profile/:navigationBarTitleText”,

`:navigationBarTitleText` do not change this text to custom name. it will not work.

0
Topic starter

Here is a solution for implementing routing with query parameters.

To use routing with query parameters, we can integrate NavigationPayLoadMessage to set and retrieve the parameters. However, it’s important to note that using this method will result in the parameters being removed when the page is refreshed.

For passing the query in navigation :

navigateToJob = (jobId: number) => {
      const message: Message = new Message(getName(MessageEnum.NavigationMessage));
      message.addData(getName(MessageEnum.NavigationTargetMessage), `Catalogue`);
      message.addData(getName(MessageEnum.NavigationPropsMessage), this.props);

      const payloadMessage: Message = new Message(getName(MessageEnum.NavigationPayLoadMessage))
      payloadMessage.addData(getName(MessageEnum.NavigationPayLoadMessage), { query: jobId })
      message.addData(getName(MessageEnum.NavigationRaiseMessage), payloadMessage);

      this.send(message);
  }

 

To get the query 

  constructor(props: Props) {
    this.subScribedMessages = [
      getName(MessageEnum.NavigationPayLoadMessage)
    ]
  }

   async receive(from: string, message: Message) {
    if (getName(MessageEnum.NavigationPayLoadMessage) === message.id) {
      const data = message.getData(
        getName(MessageEnum.NavigationPayLoadMessage)
      );
    }
  }