Initialization
Before using the LateralWrapper, you need to initialize the library with your API key:
import { initLateral } from "tailormade-headless";
initLateral({
apiKey: "YOUR_API_KEY",
userId: "CURRENT_USER_ID",
});
Usage
import { LateralWrapper } from 'tailormade-headless';
...
<LateralWrapper lateralLocationId={componentIdConfiguredInLateral}>
<div>
<h1>My content</h1>
<p data-lateral-field-id={idConfiguredInLateral}>Default text if backend is not reachable</p>
</div>
</LateralWrapper>
Development
To develop this package locally and test it in tailormade-fe, use Yalc:
-
Install Yalc globally (if not already installed):
npm install -g yalc
-
From the root of the project, run:
yalc publish
-
In the tailormade-fe
directory, run:
yalc add @bkbarry-lateral/tm-connector
-
When you make changes to this package, run the following in this directory:
yalc push --scripts --update --replace --sig
This will build the package and update all projects using it via Yalc.
-
When you're done developing and want to switch back to the npm version, go to the tailormade-fe
directory and run:
yalc remove @bkbarry-lateral/tm-connector
npm install