1.0.24 • Published 4 years ago
lightning-jsx-redux v1.0.24
Lightning-jsx-redux
This library enables use of jsx syntax with redux connect when developing lightning apps Lightning framework documentation.
Setup
npm install lightning-jsx-redux --save-dev
Add the following to your babelrc config:
{
"plugins": [
"lightning-jsx-redux/babel"
]
}
Before your lightning app is initiated you will need to provide lightning-jsx-redux
library with your redux store.
import { createStore } from "redux";
import { provide } from "lightning-jsx-redux";
export const store = createStore(myReducer);
provide(store);
Here's an example of a connected jsx component:
import { connect } from "lightning-jsx-redux";
const myComponent = (state, actions) => (
<text
x={110}
y={110}
text={{
fontSize: 24,
text: state.myState,
fontStyle: "bold",
textColor: 0xff636efb
}}
updated={(newState, oldState, self) => {
// My update logic
self.patch({
text: {
text: newState.myState
}
});
// Dispatch my redux action
actions.myFunc("someValue");
}}
firstActive={(currentState, currentProps, self) =>
console.log("First time visible")
}
active={(currentState, currentProps, self) =>
console.log("Visible on screen")
}
inactive={(currentState, currentProps, self) =>
console.log("Not visible on screen")
}
/>
);
export default connect(
state => ({ myState: state.myState }),
{ myFunc: value => ({ type: "SOME_ACTION", input: value }) }
)(myComponent);
1.0.24
4 years ago
1.0.23
4 years ago
1.0.22
5 years ago
1.0.21
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago