0.3.0 • Published 5 years ago

jspsych-react v0.3.0

Weekly downloads
47
License
MIT
Repository
github
Last release
5 years ago

Getting Started

npm install jspsych-react

You can use the Experiment component to include a jsPsych experiment in your React project. For example:

import React, { Component } from 'react'
import { Experiment } from "jspsych-react";
import { visualOddball } from "./examples/timelines";
import { callbackHTMLDisplay, callbackImageDisplay } from "./examples/plugins";

export default class ExperimentComponent extends Component {
  render() {
    return (
      <div>
        <Experiment
          settings={{ timeline: visualOddball }}
          plugins={{
            "callback-html-display": callbackHTMLDisplay,
            "callback-image-display": callbackImageDisplay
          }}
        />
      </div>
    );
  }
}

You can also import the jsPsych object to access other jsPsych functionality, such as updating the progress bar during a jsPsych experiment. For example:

import { jspsych } from "jspsych-react";

export const updateProgress = () =>
  jsPsych.setProgressBar(
    jsPsych.progress().current_trial_global / jspsychObject.sample.size
  );

API

Props

Experiment

NameTypeDefaultDescription
settingsobjectrequiredThe settings object is passed to the jsPsych.init() function and defines many aspects of an experiment. It can contain many parameters, but the only required parameter is a timeline. See the the jsPsych API documentation.
pluginsobjectnullCustom plugins to be passed to jsPsych for use in the experiment. Object keys should match the names of the plugins referenced in the timeline.

License

MIT © Teon Brooks

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago