Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1.51 KB

File metadata and controls

56 lines (41 loc) · 1.51 KB

Make Traffic Integration React Example

This example demonstrates how to use the make-traffic-integration-core and make-traffic-integration-react-wrapper libraries in a React component.

Check the React Example for the complete code.

Run the example on localhost:

git clone git@github.com:koltsov-iv/make-traffic-integration-lib.git

cd make-traffic-integration-lib/examples/react-app

npm install

env PORT=3033 npm start

Replace the PORT value with the desired port number from your Traffic source settings.

Replace the <!--YourAppKey--> placeholder in the appConfig object with your application key from Make Traffic console.

Usage

import React from "react";
import { TaskManagerProvider } from "make-traffic-integration-react-wrapper";
import {TaskManagerApp} from "make-traffic-integration-core";

const taskManagerApp = TaskManagerApp({
    apiUrl: "https://api.example.com",
    appKey: "your-app-key",
});

const MyCustomTemplate = (campaign, actions) => (
    <div>
        <h3>{campaign.name}</h3>
        <button onClick={actions.go}>Go</button>
        <button onClick={actions.claim}>Claim</button>
    </div>
);

const App = () => (
    <TaskManagerProvider
        taskManagerApp={taskManagerApp}
        userID="user123"
        template={MyCustomTemplate}
    />
);

export default App;